49,761 Topics

Member Avatar for
Member Avatar for fruitymo

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 …

Member Avatar for fruitymo
0
195
Member Avatar for Chuckleluck

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"); …

Member Avatar for Chuckleluck
0
594
Member Avatar for Cainer

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 …

Member Avatar for gerard4143
0
231
Member Avatar for Kyren5058

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 …

Member Avatar for cherrymae.calma
0
278
Member Avatar for valestrom

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 ------ …

Member Avatar for pseudorandom21
0
669
Member Avatar for dolfan55aj

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 …

Member Avatar for mike_2000_17
0
521
Member Avatar for existinglady

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 …

Member Avatar for existinglady
0
2K
Member Avatar for monkeybut

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 …

Member Avatar for mike_2000_17
1
529
Member Avatar for guccimane

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 …

Member Avatar for guccimane
0
941
Member Avatar for SquigsSquigley

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 …

Member Avatar for raptr_dflo
0
998
Member Avatar for dooper

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 …

Member Avatar for Masterlynx
0
306
Member Avatar for valestrom

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 …

Member Avatar for valestrom
0
2K
Member Avatar for ntrncx

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 …

Member Avatar for ntrncx
0
143
Member Avatar for alle

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 …

Member Avatar for amyuni
0
550
Member Avatar for PaulProgramer

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 …

Member Avatar for PaulProgramer
0
219
Member Avatar for efigen

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] …

Member Avatar for WaltP
0
99
Member Avatar for Khan Shaeen

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...

Member Avatar for L7Sqr
-1
27
Member Avatar for monkeybut

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 …

Member Avatar for monkeybut
0
4K
Member Avatar for ccoder83

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 …

Member Avatar for ccoder83
0
203
Member Avatar for Demetrio.pepi

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: …

Member Avatar for Demetrio.pepi
0
389
Member Avatar for HelpStudents

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 …

Member Avatar for arunp_eagle
0
147
Member Avatar for aspirewire

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?

Member Avatar for raptr_dflo
0
216
Member Avatar for HelpStudents

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 …

Member Avatar for tajendra
0
112
Member Avatar for DalekThay

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", …

Member Avatar for raptr_dflo
0
81
Member Avatar for Steven_gerrard

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 …

Member Avatar for raptr_dflo
0
160
Member Avatar for guccimane

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 …

Member Avatar for WaltP
0
99
Member Avatar for iAMyours

[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) …

Member Avatar for raptr_dflo
0
179
Member Avatar for Jared1337

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() …

Member Avatar for raptr_dflo
0
4K
Member Avatar for jper

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 …

Member Avatar for jper
0
477
Member Avatar for aspirewire

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 …

Member Avatar for WaltP
0
128

The End.