Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 06-11-2002, 10:00 PM   #1 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,532
sde is on a distinguished road
c++ class woohoo

i started my classes and it's pretty cool .. i'll write some really beginner nums on the stuff we are doing... they are a good introduction for c++ newbs. i like it.
sde is offline   Reply With Quote
Old 06-11-2002, 10:15 PM   #2 (permalink)
bdl
Senior Contributor
 
Join Date: May 2002
Location: vta.ca.usa
Posts: 555
bdl is on a distinguished road
sounds great! let us all bask in the glow of your c++ enlightened mind...
bdl is offline   Reply With Quote
Old 06-11-2002, 11:15 PM   #3 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,532
sde is on a distinguished road
2 words:

Code:
HELLO WORLD!
sde is offline   Reply With Quote
Old 06-12-2002, 08:13 AM   #4 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
No its C++, we need to be more Object Oriented:
Code:
class world{
   void world(){ cout << "Hello world" << endl;};
   void ~world(){ cout << "Goodbye cruel world" << endl;};
};

int main(){ world my_world; return 0;}
Note: the above code has not been tested..
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 06-12-2002, 09:30 AM   #5 (permalink)
kenshi
Registered User
 
kenshi's Avatar
 
Join Date: Jun 2002
Location: Antarctica
Posts: 43
kenshi is on a distinguished road
Send a message via ICQ to kenshi
I really need to learn C++ myself. I'm pretty proficient with C, but I just never really learned how to use classes. Hopefully I'll get the time to do it some time soon.
kenshi is offline   Reply With Quote
Old 06-12-2002, 09:53 AM   #6 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,532
sde is on a distinguished road
redhead: you are funnee
sde is offline   Reply With Quote
Old 06-12-2002, 10:00 AM   #7 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
Quote:
Originally posted by mmilano
redhead: you are funnee
Actualy, first I wanted to make a string overloading and a cout overloading, so it would be something like:
Code:
int main(){
world hello;
String world = hello;
cout << world;
return 0;
}
Given the cout would allways print "hello" and the world class would allways hold "world" as a string.

But I thought it was too much for a beginner class
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 06-12-2002, 10:14 AM   #8 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,532
sde is on a distinguished road
what exactly does overloading mean?
sde is offline   Reply With Quote
Old 06-12-2002, 11:12 AM   #9 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
Quote:
Originally posted by mmilano
what exactly does overloading mean?
A small example:
Code:
class someclass{
   String name;
  public:
    void someclass() { name="";};
    void someclass(String Name=""){name=Name;};
};
The create function for someclass is overloadet, so if you use:
Code:
int main(){ 
   someclass test; 
   someclass test1("new class");
  return 0;
}
Then in test1 case, it will use the second create function in someclass, thus assigning the name variable to "new class" the same thing is possible with allready created functions like cout you just need to create it as an operator to the given class you're creating, for the cout << it would be cout::operator << { /* what ever to do */}
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 06-12-2002, 11:30 AM   #10 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,532
sde is on a distinguished road
Quote:
But I thought it was too much for a beginner class
now this statement i understand .. the overloading is a little over my head as of now .. maybe in a couple weeks i'll look back to this post and perhaps understand.

thanks for the explination
sde is offline   Reply With Quote
Old 06-12-2002, 04:22 PM   #11 (permalink)
abc123
bloomberg
 
abc123's Avatar
 
Join Date: Jun 2002
Location: bloomberg
Posts: 263
abc123 is on a distinguished road
Send a message via AIM to abc123 Send a message via Yahoo to abc123
overloading is simple.. in java for example:

Code:
public void GiveMeVal(int x)
{
    system.out.println("x is an int equal to:" + x);
}

public void GiveMeVal(String s)
{
   system.out.println("s is a string equal to:" + s);
}
so there are TWO "methods" with the same name (GiveMeVal) but have a DIFFERENT parameter list (int x and String s).

So if we call: GiveMeVal(10); we will get "x is an int equal to: 10"
and if we call...: GiveMeVal("ten"); we get "s is a string equal to: ten"

easy!!
__________________
-- bloomberg.
abc123 is offline   Reply With Quote
Old 06-12-2002, 07:33 PM   #12 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,532
sde is on a distinguished road
hmm .. thanks =) the lights are turning on slowly
sde is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
operate overloading member function in C# sureshkumar_kc MS Technologies ( ASP, VB, C#, .NET ) 2 10-15-2004 03:36 AM
edit? anon Lounge 10 11-21-2002 04:02 PM


All times are GMT -8. The time now is 12:50 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC8 ©2007, Crawlability, Inc.





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting