64,648
社区成员
发帖
与我相关
我的任务
分享
typedef struct basetype
{
unsigned int array[3];
unsigned int m;
}BASETYPE;
typedef struct node{
BASETYPE c;
node(BASETYPE* p):next(0),prev(0)
{
c.m=p->m;
for(int i=0;i<3;i++)
{
c.array[i]=p->array[i];
}
};
void Print()
{
cout<<c.m<<endl;
for(int i=0;i<3;i++)
{
cout<<c.array[i]<<endl;
}
}
node():next(0),prev(0){};
struct node *next,*prev;
}Node;
int main()
{
BASETYPE input={1001,2,3,4};
Node* test(&input);//这里始终提示类型转换问题,而导致无法通过编译
test->print();
}
#include <iostream>
using namespace std;
typedef struct basetype
{
unsigned int array[3];
unsigned int m;
}BASETYPE;
typedef struct node{
BASETYPE c;
node(BASETYPE* p):next(0),prev(0)
{
c.m = p->m;
for(int i = 0; i < 3; i++)
{
c.array[i] = p->array[i];
}
}
void Print()
{
cout << c.m << endl;
for(int i = 0; i < 3; i++)
{
cout << c.array[i] << endl;
}
}
node():next(0),prev(0){};
struct node *next,*prev;
}Node;
int main()
{
BASETYPE input = {1001,2,3,4};
Node test(&input);//这里始终提示类型转换问题,而导致无法通过编译
test.Print();
}
/*
运行情况:
E:\Program\c\tgcc>make
g++ -o a a.cpp
E:\Program\c\tgcc>a
4
1001
2
3
*/