473,480 Members | 2,351 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

S.i considered a variable?

struct S {
int i;
};

int main() {
S myS;
myS.i; // is this a variable according to spec?
return 0;
}
Jul 22 '05 #1
4 1051
On 8 Dec 2003 09:46:38 -0800, cb*****@rogers.com (cbowler) wrote:
struct S {
int i;
};

int main() {
S myS;
myS.i; // is this a variable according to spec?


S::i is a "member variable".

Tom

C++ FAQ: http://www.parashift.com/c++-faq-lite/
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
Jul 22 '05 #2
"cbowler" <cb*****@rogers.com> wrote...
struct S {
int i;
};

int main() {
S myS;
myS.i; // is this a variable according to spec?
It is an expression of type int& (a reference to int).
return 0;
}


Victor
Jul 22 '05 #3
> cat main.cc
struct S {
int i; // public data member
};

#include<iostream>

int main(int argc, char* argv[]) {
S myS;
myS.i = 33;
std::cout << myS.i << " = myS.i" << std::endl;
return 0;
}
g++ -Wall -ansi -pedantic -o main main.cc
./main 33 = myS.i

Yes, myS.i *is* a variable.
No, S.i is *not* a variable
because you never *declared and instance of S named S
cat main.cc struct S {
int i; // public data member
};

#include<iostream>

int main(int argc, char* argv[]) {
S S;
S.i = 33;
std::cout << S.i << " = S.i" << std::endl;
return 0;
}
g++ -Wall -ansi -pedantic -o main main.cc
./main

33 = S.i

Jul 22 '05 #4
"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:Mw3Bb.271150$Dw6.928633@attbi_s02...
"cbowler" <cb*****@rogers.com> wrote...
struct S {
int i;
};

int main() {
S myS;
myS.i; // is this a variable according to spec?


It is an expression of type int& (a reference to int).


Correction:
It is an lvalue of type int (see 5.2.5/4).

And in general, an object-expression evaluates to the type of the object it
designates - lvalue or rvalue.
References evaluate to lvalues (see 5/6) .
Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

699
33298
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
25
2887
by: mike420 | last post by:
Ladies and Gentlemen, I present to you the final and ultimate proof of Python's brain-damage: As you may remember, flist = for i in range(3)
9
1558
by: mike420 | last post by:
map(lambda f: f(1), ) Oh, OK, it was a typo (1 instead of i). I take it all back (for now). It was an honest mistake, not a troll! Still, I think it should be instead of
32
3902
by: Andreas Prilop | last post by:
Here is an illustration of the warning http://ppewww.ph.gla.ac.uk/~flavell/charset/browsers-fonts.html#dont that you should not specify a typeface when you have characters outside West European...
61
5121
by: Steven T. Hatton | last post by:
Stroustrup's view on classes, for the most part, seems to be centered around the notion of invariants. After a bit of adjusting to the use of yamt (yet another math term) in computer science, I...
8
2160
by: MLH | last post by:
A97 HELP shows the proper syntax for using Nz as Nz(variant) I'm wondering what to expect from potential past misuse I've made. For example, consider the following... Private Sub...
6
1991
by: kobu.selva | last post by:
I was recently part of a little debate on the issue of whether constants and string literals are considered "data objects" in C. I'm more confused now than before. I was always under the...
3
1191
by: Tom Padilla | last post by:
I am making a map generator and for some bizarre reason I have a variable that will not come in scope. Code snippet: void placeContinents(int NumberOfContinents) { for(int Loop = 0; Loop <...
9
2723
by: Khookie | last post by:
Hi all, I was wondering what was considered macro abuse. Specifically I implemented a key-value array (or dictionary), as per below. Notice the use of macros - would that be considered...
0
7048
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6911
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7091
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5344
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4488
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2999
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2988
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1303
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
564
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.