473,406 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Do you believe it's from our C++ exam?

Caculate the value of i after each step
int x=2, y=x+30;

struct A{

static int x;

int y;

public:

operator int( ){ return x+y; }

A operator ++(int){ return A(x++, y++); }

A(int x=::x+2, int y=::y+3){ A::x=x; A::y=y; }

int &h(int &x);

};

int &A::h(int &x)

{

for(int y=1; y!=1 || x<201; x+=11, y++)

if(x>200) { x-=21; y-=2;}

return x-=10;

}

int A::x=23;

void main( ){

A a(54, 3), b(65), c;

int i, &z=i, A::*p=&A::y;

i=b.x; //.................................¢Ù

z=a.x; //.................................¢Ú

i=c.*p; //.................................¢Û

i=a++; //.................................¢Ü

i=::x+c.y; //.................................¢Ý

i=a+b; //.................................¢Þ

b.h(i)=7; //.................................¢ß

}

and another one, write down the ouput of this program

#include <iostream.h>

struct A{A( ){ cout<<'A';}};

struct B{B( ){ cout<<'B';}};

struct C: A{C( ){ cout<<'C';}};
struct D: virtual B, C{D( ){ cout<<'D';}};

struct E: A{

C c;

E( ): c( ){ cout<<'E';}

};

struct F: virtual B, C, D, E{

F( ){ cout<<'F';}

};

void main( ){

A a; cout<<'\n';

B b; cout<<'\n';

C c; cout<<'\n';

D d; cout<<'\n';

E e; cout<<'\n';

F f; cout<<'\n';

}

Jul 2 '07 #1
4 1084
jo*****@gmail.com wrote:
Caculate the value of i after each step
[..]
Aside from the use of global variables (which has its place),
and 'void main', what's your objection? Is it too easy? Too hard?
Did you find that you could do it, but most couldn't? What?
and another one, write down the ouput of this program

[..]
Again, 'void main', and the use of an obsolete header <iostream.h>.
So? Did you solve it? It's not that difficult, and I am *sure* it
addresses just the topics your course contained.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jul 2 '07 #2
jo*****@gmail.com wrote:
struct A{

static int x;

int y;

public:

operator int( ){ return x+y; }

A operator ++(int){ return A(x++, y++); }

A(int x=::x+2, int y=::y+3){ A::x=x; A::y=y; }

int &h(int &x);

};
LOL @ struct A. It is written as x and y are private.

Easy exam, wasn't it?
Jul 3 '07 #3
On 2007-07-03 09:54, anon wrote:
jo*****@gmail.com wrote:
>struct A{

static int x;

int y;

public:

operator int( ){ return x+y; }

A operator ++(int){ return A(x++, y++); }

A(int x=::x+2, int y=::y+3){ A::x=x; A::y=y; }

int &h(int &x);

};

LOL @ struct A. It is written as x and y are private.

Easy exam, wasn't it?
Maybe, but you failed. Since it's a struct all members are public by
default, so x and y are public, and the 'public:' is unnecessary.

--
Erik Wikström
Jul 3 '07 #4
Erik Wikström wrote:
On 2007-07-03 09:54, anon wrote:
>jo*****@gmail.com wrote:
>>struct A{

static int x;

int y;

public:

operator int( ){ return x+y; }

A operator ++(int){ return A(x++, y++); }

A(int x=::x+2, int y=::y+3){ A::x=x; A::y=y; }

int &h(int &x);

};

LOL @ struct A. It is written as x and y are private.

Easy exam, wasn't it?

Maybe, but you failed. Since it's a struct all members are public by
default, so x and y are public, and the 'public:' is unnecessary.
I might have expressed myself wrongly, but read again what I wrote. To
me it looks like whoever wrote it expected x and y to be private.
Jul 4 '07 #5

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

Similar topics

9
by: Vanessa BJ | last post by:
Hi. I am an amateur Java enthusiast. I currently work as a carpenter and I moonlight on the weekends as a photographer. I'm trying to transition a career change. Which Java exam should I start...
0
by: who be dat? | last post by:
I'm currently taking an online class for SQL Server which is aimed at teaching you the information you need to pass exam #70-229. However, concerns exists on my part on how good this web based...
1
by: Tammy | last post by:
Please accept my apologies for asking a question that probably has already been asked a thousand times. I tried doing a search but everyone puts generic titles to their articles on the Access MOUS...
3
by: pankaj_wolfhunter | last post by:
Greetings, I want to appear for DB2 UDB V8.1 for Linux, UNIX and Windows Database Administration (Exam 701) certification. Right now i am referring to the tutorial given in the IBM site for the...
6
by: Wee Bubba | last post by:
hello. I have decided to study for my MCAD qualifications. I am definetely going to do a core exam in "Developing Web Applications With C#". I am also doing a core exam in "Developing XML...
13
by: Vanessa BJ | last post by:
Hi. I am an amateur VB.net enthusiast. I currently work as a carpenter and I moonlight on the weekends as a photographer. I'm trying to transition a career change. Is there an exam that leads to...
4
by: mike_li | last post by:
Passed DB2 UDB 701 test, how can I prepare for 704 test (Advanced DBA)? There is not as many info. on this test as on others. Thanks. Mike
2
by: derekbarrett | last post by:
Hi, I found this article in DB2 magazine and learned about the Problem Determination Mastery Exam. I am very interested in taking the exam, however, following the links in the article leads to...
3
by: Sujath | last post by:
Hi does anyone have dumps for Exam 70-553 and Exam 70-554 If so please sent me to this mail id sujath@gmail.com Thanks in Advance Regards
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.