class Complex
{
private:
int a,b;
public:
set_data(int,int);
show_data()
{
std:: cout<<"\na="<<a<<"\n"<<"b="<<b;
}
};

Complex::set_data(int x,int y) 
{
a=x;b=y;
}

main()
{
Complex c1;
c1.set_data(3,4);
c1.show_data();
}
Error: error: 'cout' is not a member of 'std' I tired to slove this error but this is not slove

Recommended Answers

All 2 Replies

Which compiler is this? Why I ask is that iostream is a header file that contains functions for input/output operations ( cin and cout ).

You need to include header files to define the standard library features you plan to use. These should appear before anything else It looks like adding:

#include <iostream>

...is all you need for this program so far. If you add code that uses stream manipulators that take arguments, like setw() or setprecision(), then you'll also need to include <iomanip>.

I hope your class is going to teach you about constructors soon, since those are the normal (and usually best) way to initialize instances of a class or struct type.

commented: Thx Your Answer Helpful me very much +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.