49,761 Topics
| |
Hello, does anyone know how to unwrap an Object? for example z and y are of type Element and 5 is a primitive double. I can write an operator+ function to add the two object together ie (z+y) but I don't knw what to do to add 5+z, Z is … | |
So I want to make a text-based game that has different maps, displayed in ASCII art-style. I've been tinkering with fstream, and I wrote up this code: [CODE]#include <iostream> using namespace std; #include <fstream> int main() { ifstream indata; int i; int j; int k; char grid[9][9]; char letter; indata.open("grid.txt"); … | |
Hi, I found a problem with operator overloading. Consider following class: [CODE]class Number { public: int value; int operator +(int v) { return value + v; } }; Number n; n.value = 5; [/CODE] Now, n+5 successfuly returns 10, but 5+n gives error [QUOTE]error C2677: binary '+' : no global … | |
Hi there, right now my teacher wants me to make an outline of a half-diamond with numbers, using for loops, kind of like the following: [code] 1 2 3 4 5 4 3 2 1[/code] The number 5 is a user input, so the half-diamond's width would be controlled by … | |
Pretty sure this would be the right area to post this, I recently started to make this program in Visual c++ 2010, and Before I added the GCF.h form, I had no errors at all. Now I get all these 1>------ Build started: Project: Valestroms Calculator, Configuration: Debug Win32 ------ … | |
I'm a new member and this is my first post, so be gentle ;) It's been a while since I've gotten a chance to practice with recursion so to say I'm a bit rusty is an understatement. Not to mention I've never implemented it with a linked list. My current … | |
This is our new and revised program... for the registration: I thank all of those people who helped me. for the search function: so I've manage to, actually my teammate managed to get a search function working for edit function: we havent figured it out on what methods are gonna … | |
IT currently is set up for base 3, but should be able to make a couple of minor changes and convert to any base, thanks and hope it helps someone out. [code]#include <iostream> #include <cmath> #include <fstream> using namespace std; void convert_base(int v, int b); ifstream inputdata; ofstream outputdata; int … | |
I wrote a program that opens a file using the command line (cmd), calculates a bunch of numbers, then outputs the results to another file. The program works fine, but when I tried to alter my code using classes, all of a sudden the program is not fine. Here is … | |
Hi all. I know that others have posted about Rock Paper Scissors, but none of their posts are exactly what I am needing. My issue is that for my program, we are required to use at least 1 switch and 1 if statement, as well as keep track of the … | |
here is my code: [code]#include <fstream> #include <iostream> #include <string> #include <fstream> #include <string> using namespace std; void displayjulianDates(int, int, int, int, int, int); int main() { //Declare variables int month1; int day1; int year1; int month2; int day2; int year2; //Gets input from user cout << "Please enter the … | |
I have a function, kinda like a main menu. But no matter what it always picks the first statement, even if it doesn't match the parameters of it's if statement, so it nevers get to the exit game function. So I can't use my close game function, and I would … | |
how i can pass inside a vector an array? i know how to do it without classes but i don't know how to do it with constructor. i try to create a 2nd constructor that takes array of integers and the size of array and initialize a vector. header [CODE]#ifndef … | |
I am converting a program written using Borland Turbo C to M$ Visual C++ 2010. I have created a Win32 application, and have now managed to write to a window. But the font that has come out is a proportional one, and I need a fixed font for everything to … | |
Hello, I have a problem with my program that I can´t figure out. I would appreciate if someone could give me some hints on what to do. I am trying to write a program that checks how many random numbers less than a positive integer N one should generate before … | |
I have an input file that i make into a string, it looks like this "1+2+3+45*5*2" My problem is when i print the string it always prints as single characters instead of 45 i get 4 5, how do i fix this. heres a small piece of the code. [CODE] … | |
Hie....M new to this site... i have to do a project on c++ using arrays, plz suggest me some topics if u can, so please can u help me asap... | |
I am having trouble figuring out how to convert base 10 to base 3, I have tried several different attempts and this is my latest effort, anyone have any ideas. I was giving this algorithm but am having trouble creating a function for it: [B] 1. Set k to the … | |
Hi, I'm trying to create a 2D grid that would allow me to use fluid properties in each cell of the grid, which is defined by a struct. I have 3 grids: [CODE=c]Grid2D <fluidProperties> grid1; Grid2D <fluidProperties> grid2; Grid2D < fluidProperties> grid3;[/CODE] My struct fluidProperties contains 12 different properties: [ICODE]struct … | |
I am trying to compile this example [url]http://www.boost.org/doc/libs/1_42_0/doc/html/boost_propertytree/tutorial.html[/url] and I am getting the error "/usr/local/boost_1_47_0/boost/property_tree/detail/ptree_implementation.hpp:795:54: error: request for member ‘put_value’ in ‘tr’, which is of non-class type ‘bool’" in this line: BOOST_FOREACH(const std::string &name, m_modules){ pt.put("debug.modules.module", name, true); } My full error message is: make all Building file: ../src/Boost_property_tree.cpp Invoking: … | |
If I have a vector of structs [CODE] struct widgets { string widgetName; int age; int color; }; [/CODE] and widgetName had multiple words in lets say widget one type 45 blue widget two 34 yellow widget eight 46 green widget ten type 33 pink and I wanted to search … | |
I'm testing to see if the sides make up a right triangle (a^2 + b^2 = c^2), but how do I make it so that, no matter the order put in, "c" will always be the largest of the three? | |
I am running into an issue trying to use an iterator to print. I am trying to print the widget name and widget type from a class and am getting an error on the iterator part. The rest of the code works fine but any comments on that are more … | |
I am having problems with understanding this code. The program should write all permutations of first N numbers. [CODE=c] #include <stdio.h> #include <iostream> using namespace std; void print(const int *v, const int size) { if (v != 0) { for (int i = 0; i < size; i++) { printf("%4d", … | |
Hey guys, I am posting here for the first time, so please be gentle with me :P. I have an assignment of storing a text file in two arrays (one contains both char and int, whereas the other contains just numbers. The text file looks something like this: Time 2 … | |
Hi, I am trying to read an input text file. And read the last letter only and check if it is an '+' or '*'. Here is the code I have written so far, if anyone can help me, I would be very greatful. [CODE] while(input>>lastChar) //put file contents into … | |
[CODE]// initial_project.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include<iostream> using namespace std; void printmessage() { cout <<" ***WELCOME TO THE ALLOY INQUIRY PROGRAM!*** " <<endl; cout << endl; cout<< "Please Choose the Number of Your corresponding Choice\n \n (1) Aluminum Alloys \t \t (11) … | |
I'm having trouble getting this program to work for roman numeral conversion. I hope it says that i have one error, which is C2110: cannot add two pointers. here's what i have so far... ANY help would be great, thanks a bunch! :) [CODE]#include <iostream> using namespace std; int main() … | |
so im basically new at c++. i need to generate 20 entries randomly from 1-20, and each number must be unique. i was able to generate the number but i don't know how to make them unique. any suggestions?[CODE]#include <iostream> #include <stdlib.h> #include <time.h> #include <math.h> using namespace std; int … | |
I want it to say "You are correct!" when the number they guess matches the random roll but it just keeps saying this when I type in 6 as my guess, how do I fix it? This is what I wrote in the main: [CODE] int num; int die; cout … |
The End.