Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 268
  • Last Modified:

question about arrays and structs

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
  • 2
  • 2
1 Solution
<< 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';

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
beachbummAuthor Commented:
so what you are saying is that arrays and structs are combined or are they redefined in the declarations of class attributes?
beachbummAuthor Commented:
see above comment...
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>

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now