49,761 Topics

Member Avatar for
Member Avatar for arun_lisieux

Hey ppl, I was browsing thro the topcoder sample problems and came up with this one. Plz suggest some good algorithm for this. Problem Statement Note: Please keep programs under 7000 characters in length. Thank you Class Name: SquareDigits Method Name: smallestResult Parameters: int Returns: int Define the function S(x) …

Member Avatar for arun_lisieux
0
194
Member Avatar for olagh

Hi everybody, I want to declare a class having an object of another class as its member data. but I recevie compiler error: "No appropriate default constrctor available" my code samlpe is as follows: [code] class bigInt { bigInt(unsigned); bigInt(const bigInt &); unsigned *value } class RSA { RSA(unsigned); bigInt …

Member Avatar for olagh
0
150
Member Avatar for JackDurden

I keep getting an error "cannot convert parameter 1 from 'char (*)[15]' to 'Student_Type *" in the swap call. gradclass is a struct and Student_Type is the name of the struct. Im trying to sort names with this. Anyone know how to fix this? [CODE=cplusplus]void SortNames(Student_Type* gradclass, int i) { …

Member Avatar for ArkM
0
141
Member Avatar for Psykocyber

Hi I'm trying to use a vector to store function pointers, but when implemented in a class there method ceases to work. Class header: [CODE]std::vector<void (*)()> fns[/CODE] Class .cpp file: [CODE] fns.push_back(Search); fns.push_back(Print);[/CODE] Search() and Print() are (public) members of a class named Movie. This code is currently placed in …

Member Avatar for Psykocyber
0
5K
Member Avatar for denbecker

I'm a student working on STL containers which were not formally taught in class. The website I typically follow hasn't helped, and neither have my textbooks. I'm getting an assertion error with this "while" loop. Probably something obvious to someone who works with C++ STL... There's an explanation for all …

Member Avatar for Salem
0
115
Member Avatar for JaR

Hello again. I am currently using a base class for a certain type of object, which looks like this: [CODE=C++]#include <vector> template <class T> class CObject { public: inline virtual ~CObject () { } virtual std::vector<T> *Output (std::vector<int> *Input) = 0; };[/CODE] The problem, that arises from this contraption is, …

Member Avatar for JaR
0
2K
Member Avatar for phillipeharris

I have the code runnig and it is all right. but within my loop I have it set from 0- 100 but my cout << only shows 59 - 100. I have tested the code with other numbers such as 20 -50 and 0 -38 .... and I see that …

Member Avatar for phillipeharris
0
257
Member Avatar for Black Magic

Hey, I'm just wanting to know how i can make some code so no random numbers are the same, I've got this so far to get the random numbers and display them but tried this and that and couldn't get it to work. [CODE=C++]#include <iostream> using namespace std; int main() …

Member Avatar for ArkM
0
382
Member Avatar for Agni

Hi Guys, i just wrote a program to print a sentence backwards using recursion. But i'm not too happy about it, if someone can give me a more optimized solution i'll be glad. You have to use std::string class. input: where the streets have no name output: name no have …

Member Avatar for Agni
0
343
Member Avatar for linux0id

Hello everyone! I am new to C++, and still haven't got to grips with objects, inheritance etc. etc. Anyway, here's the question - [CODE]class mainFrame : public Gtk::Window { private: library *m_library; player *m_player; }[/CODE] How can member m_player, when finished playing a track, access m_library to select the next …

Member Avatar for linux0id
0
94
Member Avatar for gang

can anyone there help me about my problem in displaying a record of names,gender,annual salary and age..the inputs are the first name,lastname,gender,birthday and monthly income...i just have a hard time implementing it coz i have to use a string to deal with the name..how will i make it???just a hint....

Member Avatar for gang
0
93
Member Avatar for ++C LOVER

[CODE=LANGUAGE]#include<iostream> using namespace std; class Nibble { private: union { int number : 4; }; public: Nibble(int=0); friend ostream& operator<<(ostream&,const Nibble&); friend istream& operator>>(istream&,Nibble&); }; inline Nibble::Nibble(int n) : number(n) { cout << "constructor.." << endl;} ostream& operator<<(ostream& nout,const Nibble& n) { return nout << n.number; } istream& operator>>(istream& nin,Nibble& …

Member Avatar for Alex Edwards
0
574
Member Avatar for Shadoninja

Is there a way to save in a text based game through the MSDOS window? I want to be able to save the variables that store the mana, health, ect of a player.

Member Avatar for kidprogrammer
0
324
Member Avatar for anshulagarwal

I am using borland compiler... i need to define 4 gloabal arrays of double type that can store 5000 values like double d[5000],d2[5000],d3[5000],d4[5000].. and an array of objects of class data whose syntax is: [code]class data { public: int x,y; double s,w,e,d; }d[5000],f[5000];[/code] i am facing two errors: array size …

Member Avatar for jesseb07
0
144
Member Avatar for 2fac323

I am having a problem getting a certain part of my program to loop. I need the loop to repeat if 'Y' or 'y' is picked after a menu item is chosen. And if 'N' or "n" is picked print the receipt. I have tried numerous times to get the …

Member Avatar for VernonDozier
0
201
Member Avatar for Alex Edwards

I recently wrote a cpp file that I'm questioning. I'm unsure of whether the approach I took is correct or if it will cause damage to the heap. The goal of the project is to be able to do "clean-up" on dynamically allocated memory by storing the created object in …

Member Avatar for Alex Edwards
0
116
Member Avatar for ciencia

I need help on making a sine wave I'm trying to do the equation y = Acos(2 (pi)/B x - 2(pi)/B P) amplitude A, period B, and phase shift P. It is not working out too well so can anyone help me refine this? [code=c] #include <math.h> #include <stdio.h> #include …

Member Avatar for William Hemsworth
0
122
Member Avatar for osirus0830

Hello all, I am not taking a class or asking for help with homework. I am attempting to learn C++ on my own and I do not understand the logic within one of the sample programs within my book. [code=Cpp] #include <iostream> #include <string> int main() { using namespace std; …

Member Avatar for gregorynoob
0
183
Member Avatar for VIeditorlover

Hi, I have a gizmo attached on serial port and need to detect changes of controls signals DSR, DTR etc. no data, just changes (edge). I do it with MSCOMM.ocx and it works, but only when is CPU on idle and windows messages are delivered on time. When is load …

Member Avatar for VIeditorlover
0
121
Member Avatar for gregorynoob

given x and y (the field dimensions) and x*y numbers, (pieces of cheese on each square) calculate the best way for the mouse to get from (1, 1) to (x, y), he has to get as many cheese as possible... also you can only move closer to the (x, y) …

Member Avatar for gregorynoob
0
702
Member Avatar for phillipeharris

I am working on the code that reads an enum. It seems to point to an address instead Here is the code thanks for any help [code=cplusplus] ////////////////////////////////////////////////////////////////// //contribtor.h #ifndef CONTRIBUTOR_H #define CONTRIBUTOR_H #include <iostream> #include <string> using namespace std; //================================================================ //CONSTANT DEFINITIONS enum Gender {Male=0, Female, None}; class Contributor …

Member Avatar for phillipeharris
0
115
Member Avatar for Cosa

The aim of the program which i am writing is to convert strings of DNA. The DNA is in a text file and represented by the letters A, T, C, and G. Reading in the file and outputting the converted DNA is easy. However i want to save the converted …

Member Avatar for Lerner
0
139
Member Avatar for Manutebecker

All I need to know is how a good way to make sure integers between 1 and 52 wont be draw twice over in a for statement... I was thinking something like [code] srand (time(NULL)); int *drawn; //The card to be drawn int notdraw[52]; // All the cards that have …

Member Avatar for vijayan121
0
98
Member Avatar for Clockowl

Hi guys, I tried rewriting my C-ish C++ function to true C++, but I'm failing so far: The first function (working) [code=cpp]const visualPart * entity::getVisualPart(unsigned int wantLOD){ for(unsigned int i = 0; i < visualEntity.size(); i++){ if(visualEntity[i]->LOD == wantLOD){ return visualEntity[i]; } } return NULL; }[/code] And the second (not …

Member Avatar for Clockowl
0
96
Member Avatar for anshulagarwal

when i m using this code: its not complete code..assume everything is right... [code] for(int result=0;result<g;result++) { u1+=((a[result].real_z1*tw[result])/sumd); u2+=((a[result].imaginary_z1*tw[result])/sumd); u3+=((a[result].real_z2*tw[result])/sumd); u4+=((a[result].imaginary_z2*tw[result])/sumd); } cout<<"\n""Value of U1:"<<setiosflags(ios::scientific)<<setw(10)<<setprecision(8)<<u1; cout<<"\n""Value of U2: "<<setiosflags(ios::scientific)<<setw(10)<<setprecision(8)<<u2; cout<<"\n""Value of U3: "<<setiosflags(ios::scientific)<<setw(10)<<setprecision(8)<<u3; cout<<"\n""Value of U4: "<<setiosflags(ios::scientific)<<setw(10)<<setprecision(8)<<u4; ofstream abc; abc.open("result.txt", ios::out | ios::ate); abc<<endl<<endl; abc<<"Data at position [ "<<i<<" , …

Member Avatar for ArkM
0
424
Member Avatar for krebstar

Hi guys, its me again.. I was wondering if anyone could tell me how to test a character if it is within the ASCII range, like say in the following pseudocode: [CODE] ifstream in; in.open("file.xxx", ios::binary); if(!in) { cerr << "file.xxx could not be opened. \n"; } while (!in.eof()) { …

Member Avatar for krebstar
0
6K
Member Avatar for comondx

Please help me doing my homework. this homework done with C++ Data Structure. This is Questions: [URL="http://img520.imageshack.us/img520/4417/qqqq1gvq5.gif"]http://img520.imageshack.us/img520/4417/qqqq1gvq5.gif[/URL] [code]#include <iostream> #include <stdio> #include <assert> #include <string> #include "bt.h" class Calc { public: } ; int main() { bSearchTreeType<Calc> obj; string command; cout<<"I-Inputtheexpression"<<endl; cout<<"N-InorderTraversal"<<endl; cout<<"P-PreorderTraversal"<<endl; cout<<"O-PostorderTraversal"<<endl; cout<<"F-Numberofoperatorinthetree"<<endl; cout<<"E-Evaluatethetree"<<endl; cout<<"Q-Quit"<<endl; cin>>command; do { …

Member Avatar for Manutebecker
0
89
Member Avatar for davidleeis14

C++ reading text files I have a program which I am writing which manages a savings club. I have set up a functions which creates members (there are two members types) and outputs there data to a text file a line at a time in the format string, int, int, …

Member Avatar for Agni
0
4K
Member Avatar for vvim

Hi Group, for a project[1] I am trying to find an OS independant way to measure the amount of cpu usage and memory consumption of the program. It would be nice if I could do that in my C++ code, so I can show the results at runtime or even …

Member Avatar for William Hemsworth
2
282
Member Avatar for waldchr

Hi I have a program i was writing to solidify my knowledge of files and how to handle them. I seem to have hit a snag though. What the program does is create files based on a user inputted date and allows them to add content to the files (kind …

Member Avatar for waldchr
0
119

The End.