Skip to content

Instantly share code, notes, and snippets.

@sahilbansal17
Last active January 24, 2020 13:04
Show Gist options
  • Save sahilbansal17/a7c1209d8e2b7c2ce3ede5030b281994 to your computer and use it in GitHub Desktop.
Save sahilbansal17/a7c1209d8e2b7c2ce3ede5030b281994 to your computer and use it in GitHub Desktop.
Predict the output
#include <iostream>
using namespace std;
class A{
public:
virtual void functionA() {
cout << "function A of class A called!" << endl;
}
virtual void functionB() {
cout << "function B of class A called!" << endl;
}
void functionC() {
functionA();
functionB();
}
};
class B: public A{
public:
void functionA() {
cout << "function A of class B called!" << endl;
}
void functionB() {
cout << "function B of class B called" << endl;
}
};
int main() {
A helloA;
B helloB;
helloB.functionC();
}
#include <iostream>
using namespace std;
int a = 4;
int func(int a, int b = 13) {
int c = a++ + ++::a*3 -++b;
return c;
}
int main() {
int a1 = 5;
cout << func(a1);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment