107 Topics

Member Avatar for
Member Avatar for zck17

I've just kind of gotten bored reading over learncpp.com repeatedly, so i decided to attempt to make a couple small programs for my own enjoyment ( and to really test what I'm capable of ). I have been making this little game that I call Implicit Explicit. It's basically the …

Member Avatar for frogboy77
0
212
Member Avatar for skatamatic

I am trying to write a somewhat generic class for calculating rolling averages. It's generic in the sense that it needs to support all numeric datatypes (int, double, short and long). I'm a bit of a noobie to VB.Net and have run into a problem: [code] Public Class RollingAverage(Of T) …

Member Avatar for lolafuertes
0
163
Member Avatar for tvm78

so i have this program written and i am getting a seg fault and the stack said in operator<<. I have no idea how to fix this...It is due in thirty minutes if someone can please help me asap. Here is where i think the problem lies: [CODE]#include <iostream> #include …

Member Avatar for Ancient Dragon
0
213
Member Avatar for Idestruction

I am doing this assignment for my C++ class, and we have to instantiate 4 objects of the Student class, set the data members and then sort them according to the GPA variable. Ive whittled down the errors to just one, and I am stumped. Here is the error: error …

Member Avatar for Idestruction
0
337
Member Avatar for Sudo Bash

Hi all, I am trying to create a class to serve as a customized cout class. Right now I have made some test code to see if I can do it. Right now I am trying to make it function just like cout, but later I will have it do …

Member Avatar for Sudo Bash
0
2K
Member Avatar for xploxstriker

I've just started Python and need to write a program that tells if a string is a palindrome. Here is what I have so far. [CODE] def palp(word): if len(word) < 2: return True left_index = (0) right_index = len(word) - 1 while len(left_index) <> len(right_index): return False if left_index …

Member Avatar for snippsat
0
570
Member Avatar for mullerfourie

Hi, I need to finish a assignment on operator overloading but this one piece of code doesnt seem to make sense.. in my int main() i have int main() { Element a, b(5), c(7), d; cout << (5+b) << endl; this is just part of it, I have already implemented …

Member Avatar for mullerfourie
0
210
Member Avatar for fibbo

Hey guys! I hope what I'm about to do is not frowned upon :) I just would like some input/critics/heads up on my class definition and implementation I did for my project. I am by no means a trained programmer and I doubt my coding style is very good so …

Member Avatar for fibbo
0
213
Member Avatar for michelleradu

Error C2662: 'Event::GetTime' : cannot convert 'this' pointer from 'const Event' to 'Event &'. This is my code: [CODE] #include <iostream> #include <queue> #ifndef Person_h #define Person_h #include "Person.h" #endif using namespace std; enum EventName { _SendMessageToUserInterface, _SetPNOld, _IntroduceInfection }; class Event{ int time; EventName name; Person person; public: Event(int …

Member Avatar for michelleradu
0
357
Member Avatar for ddanbe

I saw a thread lately on this site to rotate an integer. Seemed like a fun project to do. There are probably more efficient solutions out there but this is mine, and indeed it was fun! It is mostly a demo on how you could use the less known shift …

Member Avatar for kel634
0
2K
Member Avatar for toneranger

I'm reading a big csv file into a data structure defined as such: [CODE]struct PriceInfo { double Open; double High; double Low; double Close; unsigned int Volume; unsigned int Time; std::string Date; };[/CODE] So somewhere in my main function, I have this line: // read contents of datafile by overloading …

Member Avatar for danb737
0
578
Member Avatar for thekashyap

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. [COLOR="Red"][B]A brief on problem:[/B][/COLOR] Lets take example problem for simplicity: - I have a GSM network with a cell in it. - Cell's coverage …

Member Avatar for thekashyap
3
569
Member Avatar for daianahoney

Hello forum. I cant figure out how to overload the '+' operator or maybe theres another error? Im posting from phone so excuse the slopyness. Thanks! [CODE]#include <iostream> #include <string.h> #include <ctype.h> using namespace std; class Ferma { public: static int nr_rate; static int nr_gaini; static int nr_porci; static int …

Member Avatar for daianahoney
0
234
Member Avatar for benjybob

hi, i have a small problem with the rand operator. at first i tried using it without srand but gave me the same value each time. i have inserted srand(time(0)); but my compiler throws me up these errors: 1>c:\users\ben\documents\university work\year 2\c++\code\myc++\spritelab\asteroidsgame.cpp(17): error C4430: missing type specifier - int assumed. Note: …

Member Avatar for benjybob
0
418
Member Avatar for BanKuZ

hi all, I have a class A that has a char* var, operator and methods. In addition I have a global func(char*s). I would like to run this code from the main function by adding operators to my class, I need help writing them. [CODE]A* pA; ... A** ppA = …

Member Avatar for BanKuZ
0
253
Member Avatar for arthurav

I am creating a template class for working with matrices and get an error when I try to use the overloaded << operator. This is the code: [CODE]#include<iostream> #include<string> #include<conio.h> using namespace std; template <class T> class matrice { T **a; int m,n; public: matrice(); matrice(int,int); matrice(FILE *); matrice(int,int,T **); …

Member Avatar for vijayan121
0
2K
Member Avatar for lasl0w

Hey all, I'm writing a program that is an address book using an AVL Node structure (which was provided). I defined the [I]contact[/I] class as the ItemType of the data to be inserted in each node. Initially I encountered a Segmentation fault that occured during the assignment from the AVLClass …

Member Avatar for lasl0w
0
973
Member Avatar for abuka

I've got this header and cpp.And I would like to insert this operator overloading to this .h and .cpp file. but I always got errors. Operator OVERLOADING : [CODE]istream& operator>>(istream& in, Focista& jatekos) { cout << "Add meg a focista tulajdonsagait. " << endl; cout << "Nev: " << endl; …

Member Avatar for abuka
0
233
Member Avatar for aviavyne

Hello, I have a problem which goes like this. I need to be able to design a simple class, which i have done, and it must represent any numeric value, which includes a decimal and negative value. So i need to overload the operators, because the '%' will make an …

Member Avatar for Clinton Portis
0
253
Member Avatar for cwarn23

Hi everybody. I have a question about the best way to retrieve a list of possible source values from the & operator without checking every combination between the range required. The basic problem I face is I have [B](a&b)=c[/B] I know the values of b and c but need to …

Member Avatar for TrustyTony
0
210
Member Avatar for polygon

I have a script called setuptex that is run on a terminal as [CODE]. ~/context/tex/setuptex[/CODE] I wanted to execute it from a bash script file instead of typing it each time on an interactive terminal. Since the dot operator and the source builtin command are similar, and I wanted a …

Member Avatar for vaibhav1983
0
501
Member Avatar for cosnersx

There is a sample program in my C++ book that uses the += operator, and doesn't explain how it works: [CODE]gold += silver / SILVERPERGOLD;[/CODE] What exactly does this mean?

Member Avatar for Greywolf333
0
70
Member Avatar for JwhateverJ

Is there a way to add months and their respective days in my + operator?[code]Date operator + (Date const& dt, Month const& m) { jdn_type months_to_add = m.month_; jdn_type days_to_add; gregorian_type g = dt.gregorian(); long d = std::get<1>(g); if(d == 1){ days_to_add = 31*m.month_; } else if(d == 2){ days_to_add …

0
101
Member Avatar for ana_1234

This is a friend operator overload function that used addition. It adds two mix fraction by reducing them to simplest form the adding and converting them back to a mixed number [CODE]Mixed operator+(const Mixed& f1, const Mixed& f2) { int newnum, newnum2, gcd, tmpNumerator2, tmpNumerator, tmpInteger, tmpInteger2; Mixed r; tmpNumerator …

Member Avatar for ana_1234
0
419
Member Avatar for crodriguez08

Hey there, I'm having trouble creating a multiplication function for the program as I have two classes to keep in mind (Monomial and Polynomial). And if possible, a little advice on how to make my for statements in the arithmetic operators more flexible to user input such as i<PolynomialSize, which …

Member Avatar for crodriguez08
0
1K
Member Avatar for crodriguez08

Hey there, I'm having trouble figuring out the next step of my program. What I'm trying to do is make a function that will add two polynomials, and I don't know how to exactly fix it. My first question would be if the Polynomial operator+ function is right, or whether …

0
93
Member Avatar for Garrett2011

Is there any way to inline just some selective calls to a particular function not all of them? by function I also mean class operators like assignment operator, constructors like copy constructor. The only form I know is declaring function as such at beginning and that's supposed to effect all …

Member Avatar for Narue
0
149
Member Avatar for AliHurworth

hi all. i'm struggling with the following code - can't seem to get the variables within the function to work... [CODE] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Teabag calculator</title> <script language="javascript" type="text/javascript"> var single=0; var dbl=80; var total=single + dbl; …

Member Avatar for Airshow
0
88
Member Avatar for Sinaru

I have two classes and one of them is inherited from the other class. Class Person - used to store first name and last name of a person. The data members are protected. Class Candidate - used to store votes of an election, and this is inherited from Person class …

Member Avatar for arkoenig
0
160
Member Avatar for y2kshane

can i declare operator overloading function as a friend function? i did it and i get errors #include <iostream.h> class time { int h; int m; friend time operator +(time); public: void input(); time(); time(int,int); void display(); }; time::time() { h=0; m=0; } time::time(int a,int b) { h=a; m=b; } …

Member Avatar for Stefano Mtangoo
0
292

The End.