|
int a = 5; int b = 6; int sum = a + b; // sum = 11 And when we use the + operator with strings, it performs string concatenation. For example, string firstName = "abc "; string lastName = "xyz";
// name = "abc xyz" string name = firstName + lastName; |
|
class Box { double width;
public: double length; friend void printWidth( Box box ); void setWidth( double wid ); };
|
virtual void show() = 0; // Pure Virtual Function cout << "Implementation of Virtual Function in Derived class\n"; Base obj; //Compile Time Error
|
|
try { // protected code } catch( ExceptionName e1 ) { // catch block } catch( ExceptionName e2 ) { // catch block } catch( ExceptionName eN ) { // catch block }
|
#include <iostream>
using namespace std;
class Animals { public: void sound() { cout << "This is parent class" << endl; } };
class Dogs : public Animals { public: void sound() { cout << "Dogs bark" << endl; } };
int main() { Animals *a; Dogs d; a= &d; a -> sound(); // early binding return 0; }
|