49,761 Topics
| |
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 … | |
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 … | |
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 … | |
[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 … | |
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 … | |
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. … | |
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 … | |
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 … | |
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 … | |
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 … | |
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]; … | |
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 … | |
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 … | |
.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 … | |
What is need of default arguments in function overloading in C++? | |
| |
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 … | |
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 … | |
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 … | |
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: #^^^^^^^^^# ^#^^^^^^^#^ ^^#^^^^^#^^ ^^^#^^^#^^^ ^^^^#^#^^^^ ^^^^^#^^^^^ … | |
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 … | |
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. … | |
write a c++ programme for implementing gauss-seidel interation method. | |
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 … | |
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 … | |
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 … | |
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 … | |
#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; … | |
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 … | |
#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) … |
The End.