[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
why this program can be compiled, but cannot be linked?
From: |
Andy |
Subject: |
why this program can be compiled, but cannot be linked? |
Date: |
29 Apr 2005 12:40:06 -0700 |
User-agent: |
G2/0.2 |
Hi,
I just write a small program on nested class. It can be compiled, but
cannot be linked. How shall I solve this problem? The program is as
follows:
#include <iostream>
#include <string>
using namespace std;
class A{
public:
static string str;
class B{
public:
void method(){ str = "assigned in class B"; }
};
class B b;
};
int main()
{
A a;
a.b.method();
cout<<"a.str = "<<A::str<<endl;
}
Thanks a lot!
Andy
- why this program can be compiled, but cannot be linked?,
Andy <=