49,761 Topics

Member Avatar for
Member Avatar for gretty

Hello I am unsure of the correct way to make this function below(multiply) stop if a condition is true? The reason why is because of the function type, its not an int, string, void etc, I am unsure how to stop a function whos type is the class name? Do …

Member Avatar for StuXYZ
0
90
Member Avatar for shopnobhumi

i am trying to compile it (ms visual c++) but it is not compiling, i guess there is some errors but visual c++ is only saying fatal error which i have no idea what it is.Any idea? [code]#include "stdafx.h" #include <iostream> using namespace std; int nbs=0; void Queens(int nn, int …

Member Avatar for NathanOliver
0
112
Member Avatar for complexcodes

Hey guys, I have written a recursive function mazeTraverse which finds the path of the mouse to find its food which is placed inside the maze. I am given a maze of of 15 rows and 25 columns. Mouse's starting position is (8,1)[eighth row and 1st column] and the food …

Member Avatar for complexcodes
0
173
Member Avatar for ericcool

[CODE] template<class T, int size = 50> class genClass { T storage[size]; ...... void menberFun() { ...... if (someVar < size){......} ...... } } [/CODE] which uses an integer wariable size as a parameter to template to a declaration of genClass, which does not include size as a parameter to …

Member Avatar for StuXYZ
0
181
Member Avatar for elitedragoon

So I am given a string: x = "llo"; I have a string array with a list of words: words{}={"hi", "bye", "lol"}; I have to compare x to each of the strings in the array to determine what x is if it is 'unscrambled'. What is the best possible way …

Member Avatar for StuXYZ
0
127
Member Avatar for erialclaire_238

I'm having a problem on this one. using a for loop i need to make a user guess a number from 1-10 with only three tries,,, the correct number is 3 . It's running and all but it keeps showing the cout 'Your password is correct' & Program Over everytime. …

Member Avatar for erialclaire_238
-2
1K
Member Avatar for NathanOliver

Hi all. I am currently writing a large number class and was curious if I should use a template. I am setting up my constructors and I have one for a string and i was thinking i could use a template for a constructor so it can take in an …

Member Avatar for NathanOliver
0
142
Member Avatar for edgar5

Okay, it's been a long time since I've programmed in C++! Languages change considerably in the last 5 years or so. In reviewing some source code I often see statements like this: [CODE] wxString label; if (name == wxT("Undo")) { label = _("Undo");[/CODE] obviously, I snipped out a lot of …

Member Avatar for edgar5
0
136
Member Avatar for ROTC89

ok so i am suppose to write a program that displays binary and hexadecimal as so 0000 1010 A, but some of my code shows 1C and i dont know how to fix it. please help [code=c++] /* */ #include<iostream> using namespace std; int main() { int arr[8]; char p …

Member Avatar for sandeepss6s
0
121
Member Avatar for evilguyme

i read through loads of stuff and the main thing i saw was the accept button property of the button. but i don't understand how to use this in a C++ windows form application. if there is an easier way or someone (Niek_e) can make it easier for me to …

Member Avatar for evilguyme
0
80
Member Avatar for Cosmin871

I have created a win32 application in which you can draw different objects(lines, rectangles, etc.) and now I want to save the drawings as bmp files because I already now how to load bmp files. These is as far as I got: [CODE]void OnSave(HWND hWnd) { OPENFILENAME openFile; TCHAR szPath[MAX_PATH]; …

0
44
Member Avatar for Talguy

I am creating a scripting engine that would execute my own scripting language. The engine does a double pass through the script, the first pass parses the file and builds the data structure and the second executes the script. The error I am getting is when I try to read …

Member Avatar for Talguy
0
115
Member Avatar for markrezak

ok ok i got it now right i copy it to vector and sort it..... here is the code #include <iostream> #include <fstream> #include <algorithm> #include <string> #include <map> #include <vector> using namespace std; typedef map<string,int> word_count_list; struct val_lessthan : binary_function < pair<string,int>, pair<string,int>, bool > { bool operator() (const …

Member Avatar for William Hemsworth
0
176
Member Avatar for markrezak

.the program is running .display the frequency of words and sort them from highest count to lowest. my problem is about the duplication of the counts or value of the words.if the value of the word are same it only display the first word&value ...can some one help here is …

Member Avatar for markrezak
0
185
Member Avatar for sohaib770
Member Avatar for Lerner
0
69
Member Avatar for evilguyme
Member Avatar for lostmonkey

In my readFile.h file, I define void readFileInformation(string filename) in readFile.cpp file, I define void readFile::readFileInformation(string filename) { ifstream inFile; infile.open(filename.c_str(), ifstream::in); ... } in main.cpp file, I used string filename="mgolfinput.txt" readFile filereader; filereader.readFileInformation(filename.c_str()); but for some reason, I couldn't open file. I did try to change path of .txt …

Member Avatar for Nick Evan
0
82
Member Avatar for Gaiety

Hi, Please suggest me how to check a given tree is balanced using the height of tree. we need to use the avl tree concept. i.e, the difference between height of any left or right subtree is atmost 1. i have written the code for inserting the node, but this …

Member Avatar for Barefootsanders
0
131
Member Avatar for MattyRobot

I have been trying for ages to get glut working (in code blocks) and now it works... sort of. I can compile and run applications but it comes up with several warning: ignoring #pragma comment errors in glut.h. I got the glut.h file from [URL="http://www.transmissionzero.co.uk/computing/using-glut-with-mingw/"]here[/URL]. because all other downloads of …

Member Avatar for MattyRobot
0
134
Member Avatar for shahanakazi

Hi, I'm a beginner of C++ programming. I am trying to write a void funtion for the following question but in vain. Please help me. Here's the question: Suppose we want to display the following figure containing the alphabetic character V on yhe screen: #^^^^^^^^^# ^#^^^^^^^#^ ^^#^^^^^#^^ ^^^#^^^#^^^ ^^^^#^#^^^^ ^^^^^#^^^^^ …

Member Avatar for Barefootsanders
0
159
Member Avatar for evilguyme

ok so basically i just wanted to know how to add a string variable between text.. eg. [CODE] string name; cout << "Hello,"name"sucks"; [/CODE] i want to know how to do it all in one line since where i use it there are parameters and they don't allow me to …

Member Avatar for Nick Evan
0
98
Member Avatar for samm22

Does anyone know how to truly select random element from a vector v? I tried this: int rnd; rnd = v[ (int)floor( (double)rand()*( (double)v.size() / (double)RAND_MAX ) ) ]; cout<< "Random element: "<<rnd; But every time it's selecting only one particular element from my vector. It should be random right. …

Member Avatar for samm22
0
139
Member Avatar for Anjana Patel
Member Avatar for ithelp
-1
129
Member Avatar for thisisanfield.1

This is my first time using pointers and I'm having some trouble. So far I have declared a struct named Student which is meant to hold the data for each student. There is an input file with an unknown amount of entries. Each entry has a first and last name …

Member Avatar for thisisanfield.1
0
138
Member Avatar for lotrsimp12345

When i run a black screen with cursor appears but nothing prints THANKS INTERFACE [code] //my_int_vector.h class my_int_vector { public: //destructor ~my_int_vector(); //copy constructor my_int_vector(const my_int_vector& b); //constructor that create an empty vector my_int_vector(); /*constructor that create an vector with capacity specified as a parameter but doesn't assign values to …

Member Avatar for mrnutty
0
245
Member Avatar for buriza

I am getting the following errors 25 D:\calculat.cpp expected `(' before "op" 49 D:\calculat.cpp expected `;' before "op" 53 D:\calculat.cpp `y' undeclared (first use this function) I partly suspect to change it to switch (op) but that gives more errors of the following 27 D:\calculat.cpp expected primary-expression before ':' token …

Member Avatar for NathanOliver
0
98
Member Avatar for Doughnuts

Hello, I am a newbie a C++. I was doing a program where you calculate prime numbers, and it prints prime and non-prime numbers. Here is my code, [CODE]#include <iostream> #include <conio.h> using namespace std; main() { int n = 1; int i = 2; bool IsPrime; int Max; int …

Member Avatar for Doughnuts
0
279
Member Avatar for uNpReDiCtAbLe

#include<iostream.h> main() { int opt,x,y,fact,ans; for(ans=opt;ans!=0;ans++) { cout<<"\n\t\t\t *******MENU*******" <<"\n\t\t\t[1] FACTORIAL OF A NUMBER" <<"\n\t\t\t[2] PRIME NUMBER" <<"\n\t\t\t[3] ODD OR EVEN NUMBERS" <<"\n\t\t\t[4] MULTIPLICATION TABLE" <<"\n\t\t\tYOUR CHOICE: "; cin>>opt; switch(opt) { case 1: { cout<<"\nThis program tells you the Factorial of the number you have input..."; cout<<"\nInput limit: "; cin>>y; …

Member Avatar for sfuo
0
135
Member Avatar for Frederick2

Not stuck and no real question, which is unusual for me. Just a comment. The 2nd term in a for loop establishes the condition under which the loop terminates. For example, this loop terminates when i increments to 5... for(i=0; i<=5; i++) { ... ... } It'll execute its contents …

Member Avatar for Frederick2
0
120
Member Avatar for jdub69420

#include <iostream> using namespace std; class Fraction { public: Fraction() : num(0), denom(1) {} Fraction(int num, int denom) { setNum(num); setDenom(denom); } int getNum() const { return num; } int getDenom() const { return denom; } void setNum(int num) { this->num = num; } void setDenom(int denom) { if (denom) …

Member Avatar for StuXYZ
0
124

The End.