7

I've been using Visual studio to develop a C++ application. I'm not an expert in C++, neither other languages derived from C like C#. So, studying visual studio's symbology I found a reference for the same symbol saying "Field or Variable". Correct if I'm wrong please, but this sounds to me pretty almost like "Method or Function" definition.

In C++ there are no methods, instead they are commonly called as functions. So, in C++ there are also no Fields, it's a particularity from C# which works like a variable except that it should be private and it needs to be accessed from a "Get" call. Am I wrong?

Victor Oliveira
  • 3,293
  • 7
  • 47
  • 77

1 Answers1

5

Not all variables are fields. Local variables of a method are variables, but not fields. Parameters to a method, property, constructor, or anonymous method are variables, but are not fields.

Not all fields are variables. A const member is technically a field, but it is not a variable.

Servy
  • 202,030
  • 26
  • 332
  • 449
  • 1
    Even the const variables are called variables, despite of the fact that well, they cannot vary. – PaperBirdMaster Sep 10 '14 at 15:37
  • 1
    @PaperBirdMaster You have a source for that? [The MSDN page for const](http://msdn.microsoft.com/en-us/library/e6w8fe1b.aspx) specifically says, "Constant fields and locals aren't variables". – Servy Sep 10 '14 at 15:47
  • @Servy to complete your answer, fields do exist then in C++ or it's just a concept from C#? – Victor Oliveira Sep 10 '14 at 16:00
  • @VictorOliveira To the best of my knowledge the term "field" has an identical meaning on both languages. – Servy Sep 10 '14 at 16:12
  • @Servy Well, it's more clear to me now; Although I will wait a bit more so se others opinion, if you don't mind, before I accept your answer. – Victor Oliveira Sep 10 '14 at 16:22
  • @Servy well, I have not documentation at all, but if you [google const variables](https://www.google.es/search?q=const%20variables) you can find lots of conversations about it; it is a jargoon or it is accepted as a concept? – PaperBirdMaster Sep 12 '14 at 07:20
  • @PaperBirdMaster I see lots of results, but nothing from any official sources (in any context). I only see the term used by programmers using the terms on forums and q/a sites, despite the fact that it's not technically a valid term. – Servy Sep 12 '14 at 14:05
  • @Servy so is a jargoon definitely? – PaperBirdMaster Sep 12 '14 at 15:51
  • @PaperBirdMaster In C#, yes, in C++, I'm quite confident. In other languages, that will depend. And I wouldn't call it a jargon, simply an improper use of a term. – Servy Sep 12 '14 at 15:53