anonomyss wrote: |
---|
What is Valid / Invalid access? |
I don't think these are standardized terms, but what they probably ask in this case is whether the
access specifiers (
public,
protected and
private) allow you to access the variable.
anonomyss wrote: |
---|
If something is private (x) in this case shouldn't it NOT be able to read it as its not accessible? |
Private members are accessible within the same class (and within all member functions that belong to that class).
anonomyss wrote: |
---|
Also a Valid statement. Line 32 (A objA;) is it a valid statement or not? |
I think a "valid statement" is a statement that does not give you a compilation error.
That said, line 32 is technically not a statement, but maybe that's just me being overly pedantic. If someone asked this what they probably wonder is whether this line will compile or not.
anonomyss wrote: |
---|
Like an integer is a valid statement right? |
A function contains a list of statements. Many statements end with a semicolon and are often put on their own lines. For example, the following code contains three statements, each on its own line:
1 2 3
|
int x = 9;
x += 7;
std::cout << x;
|
(assuming this code is written inside a function)
so
x
or
7
, or even
x += 7
(without the semicolon), are not statements. They are
expressions (with types). Statements often contain expressions and sometimes also other statements. Any expression can be turned into a statement by putting a semicolon at the end.
If statements and
while loops are examples of statements that don't end with semicolon (although they can
contain a statement that has a semicolon at the end).