Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 11-10-2005, 06:57 PM   #1 (permalink)
bradleyc
Registered User
 
Join Date: Aug 2005
Posts: 17
bradleyc is on a distinguished road
Struct in struct

I have seen this is mainly linked lists ... something like

struct NodeType
{
int current
NodeType *next
}

So you are obviously able to use the struct within itself?
bradleyc is offline   Reply With Quote
Old 11-10-2005, 09:01 PM   #2 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 598
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
Well, in this case you're just typing a pointer the struct contains as another of this struct, so the struct doesn't recursively hold instances of itself, just a memory address.
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote
Old 11-11-2005, 05:07 AM   #3 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
The compiler needs to be able to determine the size of an object if you create one. So you can't instantiate an object within a class the way you described. However, in your code you are creating a pointer to a class object. In that case you don't need to know the size of the actual object in advance. So this code is valid.
__________________
Valmont is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
when to use a struct sde Standard C, C++ 7 09-10-2008 05:07 AM
Struct Help... bradleyc Standard C, C++ 1 08-29-2005 03:20 PM
really stuck on deallocation problem MealMan401 Standard C, C++ 6 04-11-2005 03:18 AM
. vs -> sde Standard C, C++ 3 02-23-2004 02:21 AM


All times are GMT -8. The time now is 04:42 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting