Thread: help!
View Single Post
  #1 (permalink)  
Old July 24th, 2004, 10:51 AM
nw61 nw61 is offline
Authorized User
 
Join Date: May 2004
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default help!

1.h
#include<string>
using namespace std;
string str = "Not null!";
int inum = 123;

1.cpp
#include<iostream>
#include"1.h"
using namespace std;
extern string str; // #1
extern int inum; // #2

int main()
{
   cout<<"str is "<<str<<endl;
   cout<<"inum is "<<inum<<endl;
   return 0;
}

The compiler is vc6.0 and the result is:
str is
inum is 123

If delete the sentence of #1 £¬the result is :
str is Not null!
inum is 123

I know the sentences of #1 and #2 should be deleted,as 1.h is
a head file,not cpp file.But why the inum's value always is 123?
Does it has some matter with the compiler?




niuwei
__________________
niuwei
Reply With Quote