Why do I get these error?

Hello all,

I'm trying to make a class constructor within a namespace and I keep getting errors like: "'<variable>' is a nonstatic data member of class '<class>'" for when I try to setup parameters, and "Incomplete type is not allow" whenever I try to write out my function definition.

Here's what I'm doing:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
namespace test {
	class blah;
}

class blah {
	typedef int var[5];
public:
	blah(); // Error here if I try something like, blah(): varthis(0) varthat(0) 
	static const var a;
	static const var b;
	static const var c;
};
test::blah::blah() // Error here that there is an incomplete type
{

}


Also I'm unsure why there is a parameter of 'const blah &' when I mouse over blah(); (using Visual Studio 2010) within the class definition. It tells me 'blah::blah(const blah &)' and I am unsure where the parameter comes from. How can I resolve these issues?

Help is MUCH appreciated. Thanks in advance.
Last edited on
Ok?

1
2
3
namespace test {
    class blah;
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
namespace test {

    class blah {
        typedef int var[5];
    public:
        blah(); // Error here if I try something like, blah(): varthis(0) vartha||   t(0) 
        static const var a;
        static const var b;
        static const var c;
    };

    blah::blah() // Error here that there is an incomplete type
    {

    }

} /* test */


1
2
3
4
5
6
int main(int argc, char *argv[])
{
    test::blah blah;

    return 0;
}
blah(); // Error here if I try something like, blah(): varthis(0) varthat(0)

There are no attributes named varthis or varthat defined.


EDIT: Fixed spelling error.
Last edited on
Yes, I am aware that I did not declare varthis or varthat...

Sorry for the spelling errors. I was rushing too much to get the darn thread posted.

What I didn't know was the correct way to write out the class in the namespace. Thank you.

Also, why would there be the argument 'const blah &' in the constructor?
Last edited on
A constructor 'blah::blah' that takes the argument 'const blah &' is a copy constructor. If you don't know what one of those is, I'm sure a Google search will find you plenty of explanations. If you don't create one for your class, the compiler will create one for you by default, so that's probably why Intellisense is offering it as a possible match.
Topic archived. No new replies allowed.