I want to have a function return a struct. So, in my header file, I defined the struct and the function signature. In my code file, I then have the actual function. I get errors about “unknown type name”. Everything appears to be following a very standard format for this.
Any ideas why this isn’t working?
TestClass.h
class TestClass {
public:
struct foo{
double a;
double b;
};
foo trashme(int x);
}
TestClass.cpp
#include "testClass.h"
foo trashme(int x){
foo temp;
foo.a = x*2;
foo.b = x*3;
return(foo)
}
fooisn’t in the global namespace, sotrashme()can’t find it. What you want is this: