-3
#include<iostream>
using namespace std;

int main()
{
    ostream os=cout;
    os<<"ABC";

}

This is giving me compilation error.

lifus
  • 8,074
  • 1
  • 19
  • 24
Nitin
  • 1

2 Answers2

2

Try this instead:

#include<iostream>
using namespace std;

int main()
{
    ostream& os = cout;
    os << "ABC"<< endl;

}

ostream& os = cout; declares a reference to cout called os.

lifus
  • 8,074
  • 1
  • 19
  • 24
1

You will surely get an error as you cannot directly assign it to count... You will need to link it with the reference of ostream...

Can you change the line:

ostream os=cout;

to

ostream & os = cout

Hope it help you then...

NREZ
  • 942
  • 9
  • 13
  • It's ok @Nitin, I hope you have solved the error now... Let me know if you need any more help with understand any concepts... – NREZ Jul 10 '13 at 06:04