Can any one help me with these codes: i m freaking out here

I split my program in 3 parts.
1. main - prac.cpp
2. interface - base.h
3. implementation - base.cpp

in prac.cpp the code is:

#include <iostream>
using namespace std;

#include "base.h"

int main(){
	Base ob;

	ob.set();
	ob.get();

	system("pause");

	return 0;
}

in base.h the code is:

#ifndef BASE_H
#define BASE_H

#include <string>

class Base{
	string word;
public:
	void get();
	void set();
};

#endif

and in base.cpp the code is:

#include "base.h"

void base::set(){
	cin >> word;
}
void base::get(){
	cout << word << endl;
}

i got this error: "Error 1 error C2146: syntax error : missing ';' before identifier 'word' in "base.h" " in visual 2008


any help is highly appreciated...... thanks in advance

#include <iostream> first in your base.h

can u please explain why? i've used it already but no good...:(
why do u think i've to include it??

i got this error: "Error 1 error C2146: syntax error : missing ';' before identifier 'word' in "base.h" " in visual 2008

the error you are getting for "string". you will need to tell the compiler where string is defined. cin, cout are defined in iostream.h header file under namespace std. Also string is defined under std namespace.

Edited 6 Years Ago by ashishchoure: n/a

try
std::string word
std::cin
std::cout

Thanx it worked..:) but can you pls explain why my code isn't working. it seemed to me i got everything right. i m confused here...

This question has already been answered. Start a new discussion instead.