why is this C++code wrong? - KingPin's Forum
KPsDenKPsDen ArmoryImage HostingLegendz text RPGIp DisplayIRCFlash Arcade
Forum
      |        
Register
         my char is bugged (Posted By:vohrtechs - Replies:1 - Views:12)      « »     Ya what's open (Posted By:Bionuclear - Replies:5 - Views:70)      « »     [Check4SPAM] RE: URL Attempt (Posted By:victor2008 - Replies:0 - Views:1)      « »     [Check4SPAM] RE: URL Attempt (Posted By:victor2008 - Replies:0 - Views:1)      « »     [Check4SPAM] RE: URL Attempt (Posted By:victor2008 - Replies:0 - Views:1)      « »     Salutations (Posted By:Bionuclear - Replies:4 - Views:35)      « »     [Check4SPAM] RE: URL Attempt (Posted By:victor2008 - Replies:0 - Views:1)      « »     !!!brand new event!!! (Posted By:Bionuclear - Replies:5 - Views:87)      « »     [Check4SPAM] RE: Offer:We Offer Brand Edition Of Unlocked... (Posted By:libercom - Replies:0 - Views:1)      « »     Machinima.com Music Video (Posted By:Ego - Replies:9 - Views:110)      « »     
KingPin's Forum
 
K.P.s.N. Register vbBux / KPs Mall Bugs Blogs FAQ Search Today's Posts Mark Forums Read Donate
Go Back   KingPin's Forum > KP's Network Forum > RSS News
Reload this Page why is this C++code wrong?
 


RSS News This is a discussion on why is this C++code wrong? in the RSS News;
Description: int main() { int x=10; int y=20; cout<<*(swap(x,y)); return 0; } int *swap(int x, static y) { int t=y; y=x; ...

Reply
 
LinkBack Thread Tools
why is this C++code wrong?
(#1 (permalink))
Old
farfar is Offline
Private
Points: 149, Level: 1 Points: 149, Level: 1 Points: 149, Level: 1
Activity: 0% Activity: 0% Activity: 0%
farfar is an unknown quantity at this point
 
farfar
Rupees: 89.00
Bank: 500.00
Total Rupees: 589.00
 
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Join Date: Jan 2008
why is this C++code wrong? - January 2nd, 2008

int main()
{
int x=10;
int y=20;
cout<<*(swap(x,y));
return 0;

}
int *swap(int x, static y)
{
int t=y;
y=x;
x=t;
return &y;
}
shouldn't it print 10 in the output?
when I compile it I recieve these errors and warnings:
error C2100: illegal indirection
error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'void' (or there is no acceptable conversion)
warning C4042: 'y' : has bad storage class
warning C4172: returning address of local variable or temporary

 
Reply With Quote
Reply

Bookmarks

Tags
code, wrong

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Rupees Per Thread View: 1.00
Rupees Per Thread: 15.00
Rupees Per Post: 5.00
Forum Jump



Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
Copyright 2004-2009 KPsN


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81