use*_*726 -2 c++ graph data-structures
我在C++中有两个类
Class A
{
public:
int v;
}
Class B
{
public :
void calculation ();
}
void B::calculation ()
{
int i;
for (i= 1; i < object_a.v ;i++)
{
//some body
}
}
//now I have created an object for class A and for that object I have
//got some value for "v"
int main ()
{
A object_a();
cout << "The value of variable v in class A is" << object_a.v << ;
}
Run Code Online (Sandbox Code Playgroud)
对于上面的示例代码,我尝试使用在类B中定义的另一个函数中使用object_a检索的变量.但是它会抛出未声明的错误.有人可以帮我这里怎么去吗?
PS:我在B类中编译函数"calculation()"时遇到错误