cpp quiz

时间:2022-06-11 13:38:21
// ConsoleApplication1.cpp : 定义控制台应用程序的入口点。
// #include "stdafx.h"
#include <iostream> class MyClass
{
public:
MyClass(int* a);
MyClass();
~MyClass();
int GetId() {
return 5;
} private: };
MyClass::MyClass() {} MyClass::MyClass(int* a)
{
} MyClass::~MyClass()
{
} int main()
{
int a = 1;
int &b = a;
int *c = (int*)malloc(sizeof(int));
int d[4] = { 1, 2, 3, 4 };
c = d;
printf("%6d", b);
b = 6;
char e = 'a';
char *f = "abc";
int g = (int)malloc(sizeof(int));
void *h = malloc(sizeof(int));
std::cout << 1;
MyClass *mc = new MyClass();
MyClass m = MyClass(c);
printf("%d",mc->GetId());
delete mc; return 0;
}