Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / Java

C++ Syntax Uncovered

3.00/5 (2 votes)
15 Dec 2010CPOL 9.9K  
I have sometimes wondered if the 'with' statement would work in C/C++, just like in pascal. Meaning that it would in it's nearest scope automatically recognize class/struct members for the ones mentioned with a . or maybe -> operator.Maybe something like:TestClass* tc;float...

I have sometimes wondered if the 'with' statement would work in C/C++, just like in pascal. Meaning that it would in it's nearest scope automatically recognize class/struct members for the ones mentioned with a . or maybe -> operator.


Maybe something like:


C#
TestClass* tc;
float test;
...
with tc {
  test = .memberx * .membery;
}

Would that cause confusion in code or unsafe exposure of variables ... like opposite to namespace perhaps?


And another thing, why can't we specify the data size for enums? That cause problems when accessing data over different architectures or networks.


I know that C++0X will have that, but maybe this should go into the langauge standards?

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)