D
DanielJohnson
Hi,
I am a newbie C++ programmer, so please pardon my ignorance. I am
creating a class like shown below.
In the Class B on lines marked by asterisk(*), the compiler complains
saying "Error: expected a type specifier".
This is in visual studio compiler on windows. I tried running the same
on g++ and and g++ complained "error: expected identifier before
"false""
Can you please help me ? I am not able to figure out anything form
these error messages.
#include<iostream>
using namespace std;
namespace A
{
class A
{
public:
A()
{
std::cout<<"\n default ctor";
}
A(bool _d)
{
d = _d;
std::cout<<"\n parametrized ctor";
}
private:
bool d;
};
class B
{
public:
// this uses a1 and a2 defined below
void some_func() { }
private:
A a1(false); // This is where compiler is complaining ************
A a2(true); // This is where compiler is complaining ************
};
}
I am a newbie C++ programmer, so please pardon my ignorance. I am
creating a class like shown below.
In the Class B on lines marked by asterisk(*), the compiler complains
saying "Error: expected a type specifier".
This is in visual studio compiler on windows. I tried running the same
on g++ and and g++ complained "error: expected identifier before
"false""
Can you please help me ? I am not able to figure out anything form
these error messages.
#include<iostream>
using namespace std;
namespace A
{
class A
{
public:
A()
{
std::cout<<"\n default ctor";
}
A(bool _d)
{
d = _d;
std::cout<<"\n parametrized ctor";
}
private:
bool d;
};
class B
{
public:
// this uses a1 and a2 defined below
void some_func() { }
private:
A a1(false); // This is where compiler is complaining ************
A a2(true); // This is where compiler is complaining ************
};
}