Professional Documents
Culture Documents
02. Operator Input Output
02. Operator Input Output
class A
{
protected:
int x;
public:
A() { x = 10; }
};
class B
{
protected:
int x;
public:
B() { x = 20; }
};
int main()
{
C c;
c.fun();
return 0;
}
5. For namespace
6. Refer to a class inside another class
7. Refer to a member of the base class in the derived object
// Refer to a member of the base class in the derived object.
#include <iostream>
class Base {
public:
void func()
{
std::cout << "This is Base class" << std::endl;
}
};
int main()
{
Derived obj;
obj.Base::func();
obj.func();
return 0;
}
std::endl vs \n in C++
std::cout << std::endl inserts a new line and flushes the stream(output buffer), whereas
std::cout << “\n” just inserts a new line.Therefore, std::cout << std::endl; can be said
equivalent to std::cout << ‘\n’ << flush;
endl \n
It is a manipulator. It is a character.
It is a keyword and would not specify any It can be stored in a string and will still convey
meaning when stored in a string. its specific meaning of line break.
endl \n