Go to Post Some of the most talented people in the world are designing robots in FIRST. If that were taken away, all of us would be poorer for it. - Andrew [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Spotlight this post!  
Unread 10-29-2016, 06:54 PM
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,062
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: Syntax for 'virtual void GetDescription'?

Code:
virtual void GetDescription (std::ostringstream &desc) const =0
Piece by piece:

Code:
virtual
This means that the function is virtual. Derived classes can provide a function with the same signature that will be called instead even if you call the function through a reference or pointer to the base class. Read more here.

Code:
void
This is the return type. "void" means the function doesn't return anything.

Code:
GetDescription
This is the function name.

Code:
(std::ostringstream &desc)
The function takes a single argument (with the name "desc") of type "std:: ostringstream &". An ostringsteam is an output stream that operates on strings. String streams are useful for building strings piece-by-piece (normal C++ strings are immutable, so if you build a string by concatenating smaller strings together, you do a lot of object creation and deletion, which is inefficient). The "&" means that the parameter is passed by reference. See here for more info on the various ways you can pass arguments.

Code:
const
This means that the function is not allowed to change any internal class members (if you try, you'll get a compile error unless you use a const_cast to override this).

Code:
=0
This part is an addendum onto "virtual"...it further means that this function is "pure virtual". This means that this class is an abstract and cannot be instantiated. What good is a class that can't be instantiated? Well, you can have other classes that inherit from this one, and they can supply their own implementation of this method (in fact, they need to, otherwise they are also abstract).
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 08:25 PM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi