51,593 Topics
![]() | |
Is there any reason to check for self assignment, if you're not using array's or pointers, when overloading the = operator? For example, if the only datatypes in Vehicle are int cylinders and string manufacturer, do I really need to check before assigning? If so, what's the point? | |
Hi, I don't under what I'm doing wrong. In my line of code I have 2 outputs: The first outout returns a value, however, when I try to output the second ConsoleLine I get a value of "0"?? I'm thinking it has something to do with Converting a string to … | |
[COLOR=#0000ff]//this is the class that I must declare to be public class[/COLOR][COLOR=#000000] Zoo[/COLOR] { [COLOR=#0000ff]private[/COLOR]: [COLOR=#008000]//create 4 pointers to instances of house class [/COLOR]Animal *M; Animal *C; Animal *D; Animal *L; }; [COLOR=#0000ff]// constructor [COLOR=#000000]Zoo[/COLOR]::[COLOR=#000000]Zoo[/COLOR]() { Animal *M;= [COLOR=#0000ff]new[/COLOR] Animal(); [COLOR=#0000ff]char[/COLOR] M[64]; strcpy(M, [COLOR=#a31515]"Monkey"[/COLOR]); M->SetHouseName(M); Animal *C; = [COLOR=#0000ff]new[/COLOR] Animal(); … | |
I'm struggling with my code and was looking for a tutor. Does anyone know of a tutor available? Thank you!! | |
Hey guys. I am trying to take a normal queue and change it into a cyclic queue, which basically means that the enqueue operation will make the elements shift to make space if the rear pointer is pointing at the end of the queue. I am getting an error about … | |
I want to write a program to keep my CPU Usage to 50%.How can I do it? I just can't find the API I need to use.Anybody can help? (PS: My OS is WINXP) | |
i am getting this error : "../incl/GDS_Thread/Thread.h", line 141: Warning (Anachronism): Formal argument 3 of type extern "C" void*(*)(void*) in call to pthread_create(unsigned*, const _pthread_attr*, extern "C" void*(*)(void*), void*) is being passed void*(*)(void*). "../incl/GDS_Thread/Thread.h", line 221: Warning (Anachronism): Formal argument 2 of type extern "C" void(*)() in call to pthread_once(_once*, … | |
I have a class called Person. I also have a class called Truck, inherited from class Vehicle. I want to overload the iostream operators for all three classes so that I can do statements such as: Person a ; Vehicle b ; Truck c ; cin >> a ; cin … | |
I am trying to compare sort methods for my algorithms class and need to write all of the code for each method. My professor wants us to copy a randomly generated array and make 8 copies of it for each of the sorting methods. I'm at a loss as how … | |
All functions compile except the max function where i am trying to get it to find the maximum number in the matrix. The error message says overloaded function with no contextual type information Please tell me why. [code] #include <iomanip> #include <iostream> using namespace std; const int ROW = 3; … | |
I am trying to do a basic program that reads from a txt file and ouputs the results in a specific order on the screen. Its a salary type program. Here is my salary.txt file [code=C++] Randall Jones 25645.88 1999 Jim Johnson 56709 1992 Carol Troth 42387.05 2000 Briannal Deweyage … | |
Hi all I am a noob to C++ and I want to make a program that copies a file from wherever previously specified to the location of where the program is running from, I looked on google but I cant find anything I can understand can somebody please point me … | |
I'm having a lot of trouble designing a switch statement that can take a string value I have to read from an input file and matching it up with an enum value using a switch statement so I can process the string using a function. Complicated, I know. Here's the … | |
Hi all, Just wondering if you could help me out here. bought a copy of c++ for dummies today and the first program in the book converts fahrenheit to celsius. Now I have some C and Java experience (I am a recent graduate of a software design degree) but have … ![]() | |
I have a function in my Class which takes a char* from std input. I'm supposed to return an enum type "VehicleType". The function is part of the Vehicle class. It's supposed to return the vehicle type based on index[0] of the char*. I'm confused as how to even start … ![]() | |
Hi. I am taking a c++ class and I have to write a program that manipulates polynomials. The assignment requires that you have a largeInteger class from the STL list class. I have the code, but when I go to run it, I am having some problems. I went to … ![]() | |
Hello, I am new to c++ I am trying to write a program that reads the keyboard input while running in the background. I am on Linux. It is not easy for me because every example I find makes use of a library I do not have. When I google … | |
Hi I am reading a file with number of frames. frame 1 distance [3072] intensity [3072] amplitude [3072] w_amplitude [3072] frame 2... Now I want to read the data in structure form so that I have:- frame[0].distance[0] frame[0].distance[1].... ... frame[0].amplitude[0] ... frame[1].distance[0] and so on. My code is below and … | |
my intro to comp science teacher gave me an assignment to: 1) enter two different dates with the use of stucts 2) use a swap function to arrange each date in order from earliest to latest 3) use functions to calculate the number of days between the two dates 4) … | |
hi i m new to this forum actually i ve joined this forum coz i m havin problems in c++ i m a student of telecom will any of u plz help me in writing a code for the following programs: 1.write a program that take 5 digit number input … | |
I would like to know what would be the best way to count the nodes accessed while searching for an item in a binary search tree. I have to keep a tally for each item I search for. I have included my search method from my program. [code=cplusplus] void BinarySearchTree::find(int … | |
Good day. My infile contains the following: [CODE] TFFTFFTFFTFFTFTFTFTFFF A33 TFFTFFTFFFFFTFTFTFFFFT Z27 TFFTFFTFFTFFTFTFTFTFFT X12 TFTT FTFFTFFFT FTFTFFF H44 TFFTFFTFFTFFFFTFTFFTFF Q19 FFFFFFFFFFFFTFTFTFFFFF D72 TFFTFFTFFTFF FFFFFTFFF W32 FFFTFFTFFTFFTFTFTFFTTT Y09 TFFTFFTFFTFFTFFTTFFTTT S44 TFFTFFTFFTFFTFTFTFTFFF G11 FFTFFTFFTFFTFTFTTFTFFF J21 TFFTFFFFFTFFTFTFTFTFTT K61 TFFTFFTFFTFFTFTFTFTFT M03 TFFTFFTFFFFFTFTFTFTFFT P24 TFFTFFTFFTFFTFTFTFFFFT N54 FTFFTFFTFT TFF FTFTFFF F33 TFFTFFTFFTFFTFTFTFTFFF Z21 TFFTFFFTTFTTFFTFTFTFTF V39 TFFFTTFTTFTTFTFTFTTFFF … | |
Hi all, Have a question regarding an assignment. In a previous assignment we had to implement a program that allows us to enter a system of connected caves within an underground labyrinth. How this is implemented shouldn't matter for this next assignment though. In this assignment, we have to use … | |
hi i have used the template in my simulation program but it generate the error, my program line of code that generate the error is (these code are in queue.template file) template <class QueueItem> queue <QueueItem>::~queue() // [B]line25[/B] { } template <class QueueItem> void queue<QueueItem>::push(const QueueItem& entry) //[B]line 42[/B] { … | |
I'm getting an error in main() saying TitledEmployee is an undeclared identifier? [code=c++]#include <iostream> #include <string> using namespace std ; namespace Employees { class Employee { public: Employee ( ) ; Employee ( string theName , string theSsn ) ; string getName ( ) const ; string getSsn ( ) … | |
I have been given a problem that asks me to do the following things. Write a program should be stored in two dimensional array. The program must include the following 1. list 4 qtrly sales for 6 divisions of a company. 2. show each division increase or decrease from the … | |
hi .. please can anyone help me with this .. i need it today i wanna to do swith with this .. can i or not? if ( x>y ) cout<< " x is bigger "; else cout<< " y is bigger "; -- and i wanna to do conditional … | |
I am very new to C++ and am taking a beginners course in college. We have a project due this coming tues. and I am stuck, I was wondering if you could please help me. Background on proj: I am working in the circulation dept of a magazine, and it … | |
how do you implement a copy constructor for this pointer-based ADT queue [code] #include "Queuep.h" #include <cassert> #include <new> using namespace std; Queue::Queue () : backPtr (0), frontPtr(0) { } Queue::Queue(const Queue& Q) throw(OutOfStorageException) { //implement here }//end copy constructor Queue::~Queue() { while ( !isEmpty() ) { dequeue(); }//end while … | |
Im doing a program that asks to enter a student's grades on four exams, I have to display the four grades and the average of the four grades, to the nearest tenth. The most problem im having is using the variable call total_grade which i have to initialize to zero. … | |
is the syntax used below is correct? [code=cplusplus] class zz { private : string s; //constructor private: friend zz operator-(zz z); //assume definition of operator<< }; //constructor //operator<< zz operator-(zz z) { string s; s=z.s+"hello"; return zz(s); } int main() { zz a("fsd"); cout<<(-a); } [/code] i am new to … | |
given the equations is it possible to develop midpoint algorithm for: hyperbola :ellipse :parabola :circle ?? | |
hi there ... i am programming in dev c++ although it is very similar to tc++ but there is a certain difference between the two. so does anyone has an ebook on it or a link of any such ebook..... my email address is [i]removed[/i] | |
[CODE=c++]string a = "hello"; char b[20];[/CODE] Other than a for loop to copy character by character over is there some sort of function to convert strings to non const chars arrays? I don't even know if it exists or not but some kind of non const cast for a.c_str() perhaps? | |
So after a day or two of trying i finally found out how to do this, my question is, is there any way to do this that is more efficient without using the prime function? [code]#include <iostream> using namespace std; int main() { std::string line; int i, p, x; for(i … | |
Hi guys, How do I pass arguments into into the constructor if I'm using new to creat an array of objects? So for example: CParticle* parts; parts = new CParticle[100]; parts is declared globally, but initialised later on in the code.. my lecturer suggested this strange syntax: parts = new … | |
[code] if (decision == "B" || decision == "b"){ for (k =0; k < rows; k++){ for (m =0; m < cols; m++) switch (image[k][m] = image[k][m] + brightcount) { case '0' : cout <<" "; break; case '1' : cout <<"-"; break; case '2' : cout <<"="; break; case … | |
Hi to all I need help with this program, i have problem, i must write it out from left to right not from right to left, but i do not know how to do it, when i change something in program, than it is not working :( here is the … | |
Shouldn't [I]continue[/I] in my [I]else[/I] statement return me to the top [I]do...while[/I] loop and print the following again? [code] #include <iostream> #include <string> using namespace std; int main() { double withdraw, deposit, balance, newBalance, amount; char ans; string choice; balance = 1000; cout << "Welcome to Whatever ATM!" << endl; … | |
This is my first time posting an I need some quick help. I need to get this program to work for two players. once Player 1 loses Player 2 gets their turn. the program works fine just can't figure out the while loop for 2 player. [code=cplusplus] /* header files … | |
hey there. my problem is pretty simple (i think). I dont know how to point at a multi dimensional array.how i understand normal array pointers is: [code=C++] int numbers[5]; int *p = numbers; //so now *p points to numbers[0] //so if you say: *p = 10; //is the same as … | |
Conjunto is classtype that implements an array of pointers to some other class objects, i'm trying to overload the % operator so that the result is the join of both arrays into one. eg. array1%array2 = array1 + array2 im' trying to use methods of the class Conjunto such as … | |
hello everyone,i'm new to classes but i have adapted well with it. i've been given this task and i'm left with three days to submit.i tried it myself but i just can't get it please help. this is the problem below. proram 2 MULTICHOICE VIDEO RENTAL SHOP needs an Object … | |
Hello guys help me with a code that hides a document say for example in my documents you can email at <snipped> if you get the code or anything about c++ | |
| |
hello everybody... i am trying to make a project on binary files and that needs a function to modify data in a binary file. I have made the following class. [code] class example { public: char name[10], number[5]; void getdetails(); void showdetails(); example() { name[0]='\0', number[0]='\0'; } char* getname() { … | |
How do i terminate a loop. i have written for(int i = 0; students; i++) but it keeps on going forever and will not stop. | |
Can else have more than one statement? [code] if (control) <statement> else if (control) <statement> else { <statement> <statement> } [/code] | |
Hi, I am new to C++ and I joined this forum with hopes of learning as much as i possibly can about the language. This seems like a nice place with a mature community. I bought a C++ book and I'm just now learning the basics such as goto, for, … |
The End.