473,505 Members | 14,658 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

new a typedefed struct

There is a struct:

struct _point{
int x;
int y;
};
typedef _point Point;

struct _queue_node{
Point coordinate;
struct _queue_node* next;
};
typedef struct _queue_node Node;
typedef struct _queue_node* pNode;

Why i can't new a Node:
pNode n=new Node(); //error:no appropriate default constructor
available
i can only pNode n=new _queue_node();
Thank you
Jun 27 '08 #1
2 1493
* Vincent SHAO:
There is a struct:

struct _point{
int x;
int y;
};
typedef _point Point;
In C++ just write

struct Point { int x, y; };

struct _queue_node{
Point coordinate;
struct _queue_node* next;
};
typedef struct _queue_node Node;
typedef struct _queue_node* pNode;
In C++ just write

struct Node
{
Point coordinate;
Node* next;
};
Why i can't new a Node:
pNode n=new Node(); //error:no appropriate default constructor
available
Mysterious. Which compiler & version of that compiler are you using?
Academically it could be due to your use of names with leading underscores,
however, in practice I very much doubt that.
Cheers, & hth.,

- Alf
Jun 27 '08 #2
On 4ÔÂ16ÈÕ, ÉÏÎç9ʱ49·Ö, "Alf P. Steinbach" <al...@start.nowrote:
* Vincent SHAO:
There is a struct:
struct _point{
int x;
int y;
};
typedef _point Point;

In C++ just write

struct Point { int x, y; };
struct _queue_node{
Point coordinate;
struct _queue_node* next;
};
typedef struct _queue_node Node;
typedef struct _queue_node* pNode;

In C++ just write

struct Node
{
Point coordinate;
Node* next;
};
Why i can't new a Node:
pNode n=new Node(); //error:no appropriate default constructor
available

Mysterious. Which compiler & version of that compiler are you using?
Academically it could be due to your use of names with leading underscores,
however, in practice I very much doubt that.

Cheers, & hth.,

- Alf
Great thanks!
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
17567
by: Roy Hills | last post by:
When I'm reading from or writing to a network socket, I want to use a struct to represent the structured data, but must use an unsigned char buffer for the call to sendto() or recvfrom(). I have...
5
3276
by: PCHOME | last post by:
Hello! I am working on dividing a single C file into several files. Now I encounter a problem about the global variables and can not find a way to solve it. All global variables and codes used...
19
2587
by: Russell Shaw | last post by:
Hi, I have two structs in a header file, and they reference each other, causing a compile error. Is there a standard way to deal with this? typedef struct { ... RtAction *actions; }...
16
3810
by: burn | last post by:
Hello, i am writing a program under linux in c and compile my code with make and gcc. Now i have 4 files: init.c/h and packets.c/h. Each header-file contains some: init.h: struct xyz {
5
1197
by: Fernando Cacciola | last post by:
Hi people, I'm testing Microsoft Visual Studio 2005 Version 8.0.50727.42 (RTM.050727-4200) with our code base. I'm getting lots of errors on code that compiled fine in 7.1.
5
4311
by: Johs32 | last post by:
I have a struct "my_struct" and a function that as argument takes a pointer to this struct: struct my_struct{ struct my_struct *new; }; void my_func(struct my_struct *new); I have read...
7
2245
by: Alex | last post by:
If I have two struct. See below: struct s1 { int type; int (*destroy)(struct s1* p); } struct s2 { struct s1 base;
4
5052
by: hobbes992 | last post by:
Howdy folks, I've been working on a c project, compiling using gcc, and I've reached a problem. The assignment requires creation of a two-level directory file system. No files have to be added or...
4
9781
by: hugo.arregui | last post by:
Hi! I have two struts like that: struct { int num; int num2; struct b arrayOfB; } a;
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5613
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5028
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4699
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1528
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
407
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.