![]() |
|
|
|
| ||||||
|
Welcome to the The ProgrammersTalk Community forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| Tags: help, programming, struct |
![]() |
![]() | | LinkBack | Thread Tools | Display Modes | ![]() |
| |
| ||||
| First, you should always include any error messages. Second, I believe that struct account() { should be struct account { |
| The Following User Says Thank You to TeraTask For This Useful Post: | ||
HelloWorld (08-02-2007) | ||
| |||
| struct and class are both the same thing in C++. With one minor caveat. The default access specifier for members of a class is private. the default access specifier for members of a struct is public. Otherwise, they're identical. struct was inherited from 'C', which had no notion of OOP or classes, so, as a tradition/convention, the struct keyword is only used when the struct only contains data (And maybe some extremely trivial constructors or methods). eg, a coordinate struct for holding 2D 'x' and 'y' values in a graph Code: struct coordinate
{
int x;
int y;
coordinate(int xx, int yy)
{
x = xx;
y = yy;
}
}; //Don't forget the semicolon |
| The Following User Says Thank You to Bench For This Useful Post: | ||
HelloWorld (08-02-2007) | ||
![]() |
| Thread Tools | |
| Display Modes | |
| |