实习:
八股
代码题:
const int a; int const a; const int* a; int* const a; // 这些差别是什么
int *a; float *b; float c; long long d; // 这些sizeof是多少
struct A{ int* a; char b[10]; int c; float d }; // 这个sizeof是多少
char *s[3][5] = {"a","c","grea"}; // sizeof(s)的大小是什么
#include <iostream> using namespace std; class Base { public: // virtual void makesound() { // cout << "Base is asking" << endl; // } void makesound() { cout << "Base is asking" << endl; } }; class Derive : public Base { public: void makesound() { cout << "Derive is asking" << endl; } }; int main() { Base* b = new Derive(); b->makesound(); delete b; // Don't forget to release the allocated memory }
题外话:还是第一次这样考C++基础的,不错