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

Go Back   Code Forums > Application and Web Development > Standard C, C++

Reply
 
LinkBack Thread Tools Display Modes
Old 10-29-2005, 05:49 PM   #16 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
Just let your functions do as little as possible. Try that first.
__________________
Valmont is offline   Reply With Quote
Old 10-31-2005, 07:37 AM   #17 (permalink)
Deliverance
C++ Beginner
 
Join Date: Jul 2005
Location: Ottawa
Posts: 73
Deliverance is on a distinguished road
Do the overloaded operators count as functions, and should I simplify those? I am at a design dilemma here:

1)With my old code, inside my main() function I implicitly read-out the final results by invoking r to the overloaded ostream operator. if I take out the essentials out of that operator, my class will not let me access my data I manipulated without a function. In this case, should I create two more functions (or one) which will display my stats, and if so, doesn't that nullify the existence of my overloaded operators? (i'm using the template red provided)

By the way, I'm still working on this example, I'm just trying to re-read over the chapter on pointers, and string types as I still haven't quite figured out how the last example worked (I understand the logic part but can't trace it onto code, mainly the remove function out of the previous thread that redhead was so kind as to rework for me).

Quick question: I've read that the following type of declaration is legal:
Code:
#include <iostream>

void displaythem(int ival, int *pi, int **ppi){std::cout << ival << *pi << **ppi;};
main()
{
   int ival = 1024;
   int *pi = &ival;
   int **ppi = &pi;
   displaythem(ival,pi,ppi); //here we send pi and ppi as to not de-reference them

}
In this simple example, I can perform the operations of pointing to a pointer, and then de-referencing them as to obtain the initial value of ival with all three instances, but when would you need a pointer to a pointer in a programming scenario, which couldn't be achieved (more efficiently) by other means?
Deliverance is offline   Reply With Quote
Old 11-02-2005, 06:30 AM   #18 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
Quote:
Do the overloaded operators count as functions, and should I simplify those?
Overloaded operators are "conveniance functions". Forget about them until you implemented the class that fullfills the "use case" requirement.

In normal language, first make sure the fundamental behaviour of your class is up and running and AFTER that see how overloaded operators can simplyfie the usage of your class for your client coders (the ones that actually use your class which may include you).
__________________
Valmont 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
parse error problem in game.. can't seem to find problem solution. slashdot Standard C, C++ 5 08-03-2005 09:15 PM
JSP code problem j.gohel Java 7 04-15-2005 03:07 PM
Hashing problem jodders Standard C, C++ 1 02-09-2005 02:51 PM
Problem Assignment (Urgent help req.) Boltress Standard C, C++ 0 01-12-2005 08:59 AM
Help debugging a power problem Belisarius Lounge 0 10-25-2003 05:44 PM


All times are GMT -8. The time now is 04:04 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





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