我期待输出2,3,但我得到了垃圾值.为什么?
这是我的代码:
#include <iostream>
using namespace std;
class A
{
public:
int a, b;
A()
{
cout << a << " " << b;
}
A(int x, int y)
{
a = x;
b = y;
A(); // calling the default constructor
}
};
int main()
{
A ob(2, 3);
return 0;
}
Run Code Online (Sandbox Code Playgroud) printf() 、 scanf() 、 memset() 、 put() 等函数在头文件中都有声明,但是有没有任何机制可以查看这些函数的定义..?这可能不是一个新问题,但我找不到合适的解决方案。
我期待1作为输出..
#include<stdio.h>
int main(){
struct A{
int a:1;
};
struct A bb;
bb.a=1;
printf("%d",bb.a);
return 0;
}
Run Code Online (Sandbox Code Playgroud) c ×2
bit-fields ×1
c++ ×1
constructor ×1
definition ×1
function ×1
garbage ×1
header-files ×1
structure ×1