| Owain (143) | |
|
Hi. Just curious about the difference between classes and structures. I know that class members are default private and struct members are default public. Is there any difference beyond that? Also, is there a situation where its best to use one or the other? Or are they synonymous if you are explicit with the encapsulation? | |
|
|
|
| freddy92 (191) | |
| There is no difference beyond what you stated. Generally, structs are used when you only have data, while classes are used when you want additional functionality. | |
|
|
|
| Framework (3116) | |||||
There's 1 small difference: base classes are public, too. Other than that, there's absolutely no difference between the two.
Well, no. I consider the choice a personal preference. That being said, I use "struct" more as it more closely describes the implementation. For example: "struct array", or, "struct stack"; both are "struct"ures. I find that "class" is not as descriptive as "struct" in most cases.
As you & I said, there's no difference between the two, other than the said differences. Wazzak | |||||
|
Last edited on
|
|||||