I need some help with designing and returning a structure. I have done a similar type of structure and am getting an error saying:
"The a in class c is not a type"
How can I fix this?
ah
#include<stdio.h>
struct a {
int i;
vector<abc> j;
};
bh
#include <a.h>
class c{
private:
a a_;
virtual bool execute();
void compute(&a a1)
public:
a function_name();
}
b.cc
#include<b.h>
c::execute()
{
a aa_ = function_name();
}
d.cc
#include<b.h>
c::a c::function_name()
{
compute(a_);
return *a_;
}
bh
includes ah
, a
is a type at the global scope, a a
didn't inherit c
namespace magically
You'd need c::a
if you had a
declared inside c
declaration:
class c{
private:
struct a {
So fix is to remove namespace from c::a
:
a c::function_name()
note: the naming conventions used here (if there are some) don't help to understand those examples.
also: void compute(&a a1)
doesn't compile, should be void compute(a &a1)
, and return *a_;
should return a reference so return a_;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.