49,761 Topics
| |
How I can do it? I want a constructor of a object to have parameters, this object is inside other class..the compiler say the class dont have proper default constructors..(error C2512) [CODE=C++] ... class Game{ private: Player P1; Player P2; public: Game(void);//constructor ... [/CODE] [CODE=C++] class Player{ private: int x;//player … | |
Hi, new to the forum, I am currently studying the basics of C++ and we have an assignment in which we have to code a Sudoku validator. Basically the validator will ask for a file to be input, it will read the file and the user will be able to … | |
The problem is A voltage source supplies a load through a resistor. The voltage source has a rating of 1000 volts and a power rating of 10000 watts. The resistor is 5 ohms with a power ratings of 118.975 watts. The resistance of the load may vary randomly between 200 … | |
I have a program to write and im stuck. It runs but not properly. idk i think my "if" "else" statements are the problem. here are some sample runs Enter employee ID ====> 123 Enter payroll status (s/h/c)====> s Enter monthly salary ====> 5280 Employee ID: 123 Payroll Status: Salaried … | |
have to compute a function that calculates a sum in between a range let say user enters value of 10 and end value of 15 and then it is divided by a a divisor entered by the user say 2 I have the following code but its not working quite … | |
[code=cpp] template<typename T> //T is a type which supports the dereference operator void foo(T& param){ //the type of expression *param is defined at compile time U = *param; //U is the type which *param returns } [/code] My question is: How can I implicitly determine the return type of performing … | |
I'm studying for one of my exam's and this is my first c++ class and my professor gave one of these questions for our study guide... and I'm having trouble with it. And since our final is open book and open notes he's not giving us the answers, and i've … | |
Im looking to learn more and powerful functions like winsock to use in my dev C++ programs, Im more into the field of making application like that I really would want to learn all the necessary functions in winsock to make a simple ping program, I googled and search this … | |
When I run this program using the F or R choice the first output repeats twice, and I can't figure out why. The rest of the program works great. Prog8.cpp [CODE] #include "stdafx.h" #include "ModifyT.h" #include <iostream> #include <string> using namespace std; int main() { char ch; char exitLetter; char … | |
This is the question asked, your help is very much appreciated : One of your professors has asked you to write a program to grade her final exams which consist only of 20 multiple-choice questions. Each question has one of four possible answers:A,B,C or D. The file CorrectAnswers.txt , which … | |
hi I have a problem finding the lowest and highest selling product in this question. Can you please help me ? this is what I have . It also wants me to display the name of the salsa not how many jars were sold how do I include that in … | |
Hello! I'm new here and I'm trying to make a craps game as a project. When i get to a certain function where the player rolls and makes a point, then has to match that roll, I keep getting stuck in a loop. I'll paste the function that this takes … | |
I have an assignment to submit tomorrow. It gives me compiling errors. About 62 in VC++ 2008 and 42 in VC++ 6. I have written this code in one single file and it works fine there. One error that I can think of is with the declaration of class variable … | |
Hi everyone. I am new to this web site. Found it while doing some research. My need is as follows: I am modifying a healthcare Practice Management System for a company in Jacksonville, Fl. and the client wants to be able to create basic BAR and PIE charts. There is … | |
Thanks in advance for your help. The problem is this: I am supposed to read an array from a file and ask the user to input a name to search for within the file. If the name is there then return the position number in the file, if not output … | |
Hi there, The Wallis product is defined here: [url]http://en.wikipedia.org/wiki/Wallis_product[/url] I am having a problem with the following code, which attempts to approximate the product: [CODE]#include <iostream> #include <cmath> using namespace std; int main() { int n = 2; // initialise top counter as 2 for the first two terms int … | |
Ok, I'm not too sure if this would be considered a matrix, but what I'm trying to do promts the user for 2 characters, and one integer. For example, say you key in * G 3 the cout would be... *G* G*G *G* If you keyed in % $ 5 … | |
According to this: [url]http://www.parashift.com/c++-faq-lite/templates.html#faq-35.13[/url] One way to keep only the function declaration in the .h file is to do this [code] ////////// file: Tools.h #include <iostream> #include <vector> using namespace std; template <typename T> T Sum(vector<T> &V); [/code] [code] ///////// file: Tools.cpp #include "Tools.h" #include <iostream> #include <vector> using namespace … | |
Dear AncientDragon I have been learning c++ for two months only. Now,I am trying to understand pointers in c++.Your advise always be helpful to me. As far I understand a pointer is an address.As an example p1(pointer1) has this {x1,y1} address.So Pointer2 has {x2,y2}. There should be three different files … | |
trying to get the program to run but there is an error in line 31 (expected primary expression before else) i dont know what to do [code=cplusplus] // Devin Southern // COSC 112 - Spring 2009 // Dr Stone // Lab 9 // This program will use loop to keep … | |
I'm new to this and I'm a beginner at c++. I need some help with some questions that I've been trying to solve for hours. I think I got most of this one right but I got stuck at the wages array. This question says : write a program that … | |
To remove duplicates from a vector, my first thought was to insert them all into a set, it would take care of the uniqueness of the elements, and then read them back out into my vector. However, I have a vector<Point>, where Point is a point in 3d space (ie. … | |
The assignmento I have to write is to Derive a class DistSign from class Distance which contains inches and feet as a protected data, to add unary + or – to the distance. Write no argument and two argument constructor. Here is my program. I don’t know how to add … | |
This is a part of the problem in my homework. I have : int alpha[20]; int beta[20]; int inStock[10][4]; I need to write a function copyAlphaBeta that stores alpha into the first five rows of inStock and beta into the last five rows of inStock. my program is here, but … | |
Hello All I am having some problems with a C++ class that i am taking and after looking around on the web I am still lost. The assignment that I am working on right now is as follows: [ICODE]Two numbers are entered in from the keyboard. If the larger number … | |
I'm trying to create a simulation for a service line at a super market. The program builds just fine, but when I run it, I get: "Debug Assertion Failed! Program:... File:c:\program files\microsoft visual studio 8\vc\include\deque Line: 97 Expression: deque iterator not dereferencable" [code=c++] #include "stdafx.h" #include <iostream> #include <queue> #include … | |
hello everybody! As far as I understand, the functions that are only different in return type are not allowed. But how can I write the program for the following question? ***************************************** Create two classes DM and DB which store the value of distances. DM stores distances in meters and centimeters … | |
In this program, although I use Ignore(1000,’\n’); why it does not show the title for tape. In fact, I don’t understand very well about Ignore(); what is the meaning of 1000 in that function? [code] #include<iostream.h> class Publication { char title[20]; float price; public: void putdata() { cout<<"\nEnter title:"; cin.getline(title,20); … | |
Hi I would like to learn how to make a .s3m player in c++. Thanks | |
Hello, I have some weird problem with this code. The problem is that when I use >> to read data a text file to vector. It will only add the first double and discard the rest. Anyway if I use array instead of vector it works fine. Anyone know what … |
The End.