Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

question about arrays and structs

Posted on 2000-04-25
5
Medium Priority
?
265 Views
Last Modified: 2012-05-04
Can arrays and structs be used in the declarations of class attributes? if so are they combined or redifined? i was told in C++ you no longer need to use typedef name for a structure or use the struct keyword. any help on this would be appreciated! thanks in advance
0
Comment
Question by:beachbumm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 1

Expert Comment

by:Jmccp
ID: 2749274
<< Can arrays and structs be used in the declarations of class attributes? >>

Yes they can.  Say you have a structure:

struct struct1
{
   char abc[10];
   int def;
   long ghi;
};


Now in a class declaration below:

class class1
{
   char string1[20];
   struct1 aStructvar;
}

Here we have a class called class1 that consists of a character array and another struct.  You reference the above array as follows:

class1 classVar;
classVar.struct1.abc[0] = '\0';
classVar.struct1.def = 150;
classVar.struct1.ghi = 233124;
class1.string1[0] = '\0';

-Jim
0
 
LVL 1

Expert Comment

by:ntdragon
ID: 2749275
in c++ you don't use structs you use class

it's alot better with some intersting and usefull opetions

but ofcourse you can use arrays and structs in class's you even can make class's in other class's

do you want to how anything else
0
 

Author Comment

by:beachbumm
ID: 2751284
so what you are saying is that arrays and structs are combined or are they redefined in the declarations of class attributes?
0
 

Author Comment

by:beachbumm
ID: 2751363
see above comment...
0
 
LVL 1

Accepted Solution

by:
ntdragon earned 30 total points
ID: 2752399
what i'm saying is you can and may use them together but if you use classes you don't need structs

<or i really didn't understood your question>
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question