Quick accessor question...

I'm currently learning C# from a book and have a couple of questions that someone could maybe clear up for me:

1) Am I right in thinking that C# is the next iteration of C++ and that you can do everything in C# that you can do in C++ ?? Or is C++ the daddy and C# a kind of 'watered down' version??

2) I'm just learning about Accessors and encapsulation. In the book they demonstrate this with:

1
2
3
4
5
6
7
8
9
private int foo;
public int Foo () {
set {
foo = value;
}
get {
return foo;
}
}

My question is: Does the accessor need to have the same name as the private variable but just with a capitalised first character ? Is this set in stone or is this just a 'rule of thumb'.

Thank you for any help you can give me.

Cheers

John ;-)
closed account (z05DSL3A)
1) Am I right in thinking that C# is the next iteration of C++ and that you can do everything in C# that you can do in C++ ?? Or is C++ the daddy and C# a kind of 'watered down' version??

No. C# is not the next iteration of C++.
...Does the accessor need to have the same name as the private variable...

Again, no.
GW,

Thanks for the reply.

So... if C# is not the next iteration of C++, what is it?

Basically, I suppose I'm asking, if I learn C# will I be able to program in C++ ? How different are the two languages? And why have C# if you can do everything in C++ ?

Thanks
closed account (z05DSL3A)
C# is a language made by Microsoft for use with their .net initiative.
See: http://en.wikipedia.org/wiki/C_Sharp_(programming_language)

if I learn C# will I be able to program in C++ ?

Not directly, would would still need to learn C++ but you would have experience in programming so it would make it easier to learn. Some people do not recommend C++ as a first language.

How different are the two languages?

They have a vague similarity in syntax...more than that I would not want to say.

And why have C# if you can do everything in C++ ?

Why have any other language if you can do everything in C++? Some languages are designed to do certain thing very well but others thing may not be able to be done or do them very badly. C# was designed be used with the .net framework, something that C++ can not do. You can not use C# for anything other than the .net framework.
Thanks for the clarification GW. Much appreciated.

Thanks again for all your help.

John ;-)
Topic archived. No new replies allowed.