48,986 Topics

Member Avatar for
Member Avatar for stereomatching

At first, I wrote something like this [code] template<typename T, size_t size> inline size_t const sizeof_array(T const [size]){return size;} [/code] but if failed, then I find a solution form the other place, like this. [code] template<typename T, size_t size> inline size_t const sizeof_array(T const (&)[size]){return size;} [/code] what is the …

Member Avatar for vijayan121
0
177
Member Avatar for Vermouth

I need to write a poker game that simulates a penalty kick in a soccer match. Three cards are drawn randomly. [CODE] void DrawCard(int& numberOne, int& numberTwo, int& numberThree) { RandNoGen(); //init random number generator numberOne = rand() % 13 + 1; //random number in [1, 13] do { numberTwo …

Member Avatar for WaltP
0
278
Member Avatar for plang007

First of all, this is not schoolwork but rather me trying to read about c++ and through program examples and see if I can write my own. So help is much appreciated if you could as I am a new learner. This program that I am writing is supposed to …

Member Avatar for plang007
0
524
Member Avatar for rcmango

Hello, I've created something, its quite large, however I decided to write it without using oop, now I believe I see why I should just use oop. Okay, so the problem is with my bool values specifically: [CODE]button_pickup2 = false; button_pickup1 = true;[/CODE] For some reason when the ReflexAgent function …

Member Avatar for gerard4143
0
310
Member Avatar for trantran

[CODE] class C{ friend class F; private: fct1(){} fct2(){} fct3(){} public: fct_for_everyone(){} }; class F{ }; [/CODE] F is a friend of C, so it has access to fct1,fct2,fct3. But in real life, friendship has limits! You don't want to reveal everything! So is there a way in C++ to …

Member Avatar for mike_2000_17
0
156
Member Avatar for Thomas Tong

}[CODE]#include <stdio.h> #include <string.h> struct cd_detail { char group[20]; char name[50]; int year; double price, playtime,costTotal; } cd[7]={{"Alan","Tibet sing",2008,51,600}, {"Thubasa","Fly away",2007,52,700}, {"Alan","I love China",2010,53,500}, {"pitbull","Jump to jump",2005,54,720}, {"pitbull","crazy mix",2009,48,630}, {"pitbull","Let we ROCK",2010,49,608}, {"Alan","Sakura mansume",2010,56,909}}; void main() { char group[20]; int k; printf("Enter group>"); gets (group); printf("Name \tYear \tPrice \tPlaytime\n"); printf("========\t=======\t======\t=============\n"); …

Member Avatar for vidit_X
0
232
Member Avatar for guccimane

Hi All. I am trying to learn linked lists, and I am a little bit confused what the next pointer as well as the head pointer does. I was reading a tutorial online, and they gave this example. [CODE]#include <iostream> #include <string> using namespace std; struct Family { string nameOfFamilyMember; …

Member Avatar for vidit_X
0
101
Member Avatar for Sunshine2011

Within this code I would like to save the data which was input through a function "SavePlayer", but it doesn't work. The compiler "says" that object "a" ist not known. Probably the bold line [CODE][B][I]a.SavePlayer(manyPlayer,Player a); [/I][/B][/CODE]is wrong, but I have no idea how to solve the problem. Maybe someone …

Member Avatar for dluz
0
99
Member Avatar for Frederick2

I'm passing a this pointer in my constructor initialization list for use by a base class and VC9 gives me this warning about it... main.cpp(124) : warning C4355: 'this' : used in base member initializer list The program runs perfectly as compiled by VC9 Pro or Code::Blocks 10.05. In Code::Blocks …

Member Avatar for mike_2000_17
0
274
Member Avatar for sergent

In all the new IDEs when using open and close curly brackets the auto-formatting usually indents, and uses the extendable block (with the + sign) even if it is not necessary. For example, I like when all my functions have there own little extendable block but when I place them …

Member Avatar for dospy
0
98
Member Avatar for Muel12

Hello Everyone My background: Civil/Structural and Mechanical Engineering. I work as a Structural Engineer designing bridges. I would like to develop a program that analyzes and design structures but do not know much about software development. I have created a library of spreadsheets that are very powerful and when working …

Member Avatar for Muel12
0
151
Member Avatar for dospy

i've downloaded the last version of boost(1_47_0) but i don't know how to build it, i tried to find a tutorial on google but that didn't help much because it was for a very old version and some thing changed. anyway, my compiler does have minimal support for C++0x, will …

Member Avatar for dospy
0
148
Member Avatar for Will Gresham

Hello all, I have an issue with a class I am writing which is supposed to be able to multiple 2 matrices together. The issue I am having is not the actual multiplication (That bit works, thanks for the pointers yesterday). The problem, or so I assume, is with my …

Member Avatar for Fbody
0
148
Member Avatar for khalid_farooq

[CODE]/* * hello.c * This is a simple, introductory OpenGL program. */ #include<stdlib.h> #include <GL/glut.h> #include<iostream> #include<fstream> using std::fstream; using namespace std; void draw(void) { /* clear all pixels */ char fileName[] = "house1.txt"; fstream instream; instream.open("c:/house1.txt",ios::in); if(instream.fail()) return; glClear (GL_COLOR_BUFFER_BIT); GLint numstrip,numlines,x, y; instream>>numstrip; for(int j=0;j<numstrip;j++) { instream>>numlines; glBegin(GL_LINE_STRIP); …

Member Avatar for gusano79
0
614
Member Avatar for swissknife007

[CODE] #include<stdio.h> #include<conio.h> void hello() { printf("\nHELLO\n"); } int main() { hello(); hello(); hello(); hello(); getch(); return 0; } [/CODE] If I run this code on a compiler,how many processes and how many threads will be running on the compiler and which ones? Does a duplicate function call consist another …

Member Avatar for gerard4143
0
184
Member Avatar for Zssffssz

Ok how do I change the texts color without changing all the couts to printfs and without using system("color hex")

Member Avatar for Narue
0
202
Member Avatar for Zssffssz

Sorry about the typo in title. Ok my school is addicted to making us mad and have blocked command promp that I brought my copy from home on a floppy disk and it blocked me. So what I need is a few alternatives for these: cls - clears the screen …

Member Avatar for Narue
0
135
Member Avatar for sanuphilip

Detail on command line arguments with sample program to simulate the following DOS commands using cmmand line arguments - 1. copy 2. type 3. del 4. dir 5. rd

Member Avatar for dospy
-1
329
Member Avatar for etangryk08
Member Avatar for Evilfairy
0
394
Member Avatar for ayesha08

Our teacher made us make a program that computes midterm grade. I have made my code already. My problem now is that whenever i run my code, halfway through the end appears a debug error saying that i was using a variable(TotalCS) that isn't declared. but it is actually declared. …

Member Avatar for Evilfairy
0
235
Member Avatar for Sunshine2011

Within a function a vector could be given back via "return". Example: [CODE] vector<int>myvector() { vector<int>myvector; return myvector; } [/CODE] Better would be to work with a reference, e.g.: [CODE] vector<int>(&myvector)() { vector<int>myvector; } [/CODE] But this reference doesn't work. Does anyone have an idea what the correct code would …

Member Avatar for vijayan121
0
156
Member Avatar for Zssffssz

ok all I need is to do is put qoits in cout. Like cout<<"She said"this""; or something like that. It is not dissus able I need quotation marks in it. (makeing JavaScript thing from inside program with user imput.) Just tell me how to do it instead of alternative ways …

Member Avatar for vijayan121
0
101
Member Avatar for NoUserNameHere

I'm trying to mix it up with operator overloading and I can figure out what I'm doing wrong. Here's the code: [CODE]#ifndef TEST_H #define TEST_H using namespace std; template <typename T> class Test { private: T number; public: Test(T); friend Test operator+(Test<T> &a, Test<T> &b); friend ostream& operator<<(ostream& out, const …

Member Avatar for vijayan121
0
70
Member Avatar for ravi543

[CODE]#include<stdio.h> #include<malloc.h> struct node{ int info; struct node *link; }*start; void main(){ start=NULL; int n,i,el; printf("Enter the no. of elements u want 2 enter"); scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d",&el); createlist(el); } void createlist(int data){ struct node *q,*tmp; tmp->info=data; tmp->link=NULL; if(start==NULL) start=tmp; else {q =start; while(q->link!=NULL) q=q->link; q->link=tmp; } } struct node *q; …

Member Avatar for ravi543
0
97
Member Avatar for Kron

Okay, so my problem is that I'm making a program that identifies whether the user input is a letter, a number between 0-9 or a symbol. This is what I have so far: [CODE]#include <iostream> #include <iomanip> #include <windows.h> #include <string> using namespace std; int main() { char variable; cout …

Member Avatar for limaulime
0
91
Member Avatar for sanuphilip
Member Avatar for Richiemiz

Hi I'm having a lot of problems with this homework problem due tomorrow. The assignment is to make a program that can read data from a file and give out the wind chill, average temperature, average air speed, and average wind chill. It must also reject data that has a …

Member Avatar for WaltP
0
522
Member Avatar for ThuggyWuggy

I attempted to overload the == operator for one of my classes, I even copied a previous implementation of it, but now that I am using pointers it refuses to function properly here is the relevant code (there is a lot so I will provide more if need be) [CODE]#ifndef …

Member Avatar for ThuggyWuggy
0
6K
Member Avatar for ksm092

Hi I am trying to assign 5 people various objectives between day0 and day13. However the output is not correct and goes fuzzy in the second half of the output. This is my code: [CODE]for(int x=1, y=0; y < 5, x < 15; x++, y++) { array[x][y] = objectives[y]; if …

Member Avatar for ksm092
0
110
Member Avatar for ksm092

The End.