19 Discussion / Question Topics
Remove Filter I know that there is a sticky thread and i know that maybe i repeating things that already mentioned but i am totally confused. I am interested to study about game programming,i don't study i bought a book and i am near to finish it about c++. i goggled and … | |
i try to understand how it works. its supposed to work but isnt. the following code shouldnt be working?what i do wrong? i receive the constructor values. [CODE]#include "Person.h" #include <iostream> #include "fstream" #include "cstdlib" using namespace std; int main() { fstream file("malakia.dat", ios::out | ios::in | ios::binary); Person data; … | |
hey all i am studying from a book,and i have to do an exercise. i dont want code or anything i want tip or someone explain me how to do it. i have a oldmast.dat file with some records a trans.dat file with records and i have to update the … | |
i do an exercise and i have 2 questions. the exercise is to take an array example from my c++ book and make it template. for start my code is this: [CODE]#include <iostream> #include <iomanip> #include <cstdlib> #ifndef ARRAY_H #define ARRAY_H using namespace std; template<typename T,int elements> class Array { … | |
I do an exercise and i wrote this code to test templates [CODE]#include <iostream> #include "Date.h" #include "Time.h" using namespace std; template <typename T> bool compare(T first,T second){ if (first==second) return true; else return false; } template <class T,class X> bool compare(T first,X second){ if (first==second) return true; else return … | |
1) what exactly is the difference in a constructor if you put reference on it? example[CODE]ConstructorX(string first):firstName(first)[/CODE] with [CODE]ConstructorX(string &first):firstName(first)[/CODE] 2) [CODE]const Array &operator=(const Array&)[/CODE] the first const what exactly means?the const in the parenthesis is that the object is constant if its at the end means the function cannot … | |
i am fixing something and i have that fuction in it [CODE]bool DeckOfCards::checkFlush(const Card checkCards) { counter=0; cardCheck=" "; for(int x=1;x<5;x++) { cardCheck=checkCards.suits[x]; for(int y=0;y<5;y++) { found=hand[y].find(cardCheck); if(found!=string::npos) { counter++; } } if(counter==5) { return true; } counter=0; } }[/CODE] it goes here: [CODE]bool result=false; if((result=checkFlush(checkCards))==true) { return winner=5; }[/CODE] … | |
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 … | |
hey again i do that problem from my book, worked but i am pretty sure is not the exhaustive technique that book is asking cause i didnt have success and was too fast. i tried a counter and do 64x64 loops or 4096 loops. so my question cause i couldnt … | |
ok lets say that we have the numbers 5,67 and 128 (the numbers are randomly entered) i want in first loop read the last digit means 5,7,8 in the 2nd pass i want the tenths so will be 0,6,2 in the 3rd will be 0,0,1 and so on. what i … | |
what is wrong with my code? in inputs like "radar" or "tttt" should say its palindrome. [CODE]#include <iostream> using namespace std; bool testpalindrome(string,int,int); int main() { string wordX; bool result; cout<<"Enter string: "; getline(cin,wordX); result=testpalindrome(wordX,wordX.length()-1,0); result==true ? cout<<"\nthe string is palindrome!" : cout<<"\nthe string is NOT palindrome!\n"; } bool testpalindrome(string … | |
here are some questions that i have to improve my code readability since i study alone and my code starts to be more big and more chaotic i have some questions that maybe will sound silly to more but i have to ask someone. 1- its better to declare global … | |
i write a program that goes as follows a part of it is: [CODE]#include <iostream> using namespace std; const int size=8; const int plus[]={1,2,3,4,5,6,7}; const int minus[]={-1,-2,-3,-4,-5,-6,-7}; int vertical(int[][size],int&,int&); int horizontal(int[][size],int&,int&); int diagonal(); int main() { int board[size][size]={}; int accesibilityboard[size][size]={}; int currentrow=3; int currentcolumn=4; int counter=0; } int diagonal() { … | |
as always since i am not student i study for hobby from a book, i dont ask for code or tell me the answer only for advices to help me understand better things its the first steps of a moving knight in a chessboard,i had to make it move randomly … | |
ok i have i want to summarize only the first collum [CODE]int counter=1; int totalvertical=0; int i=7,k=4; int array[i][k]={random values}; for (int x=1;x<7;x++) { for (int y=0;y<4;y++) { cout<<"["<<x<<"]["<<y<<"]="<<array[i][j]<<" "; totalvertical=array[counter][0]; cout<<totalvertical; } counter++; cout<<endl; }[/CODE] line 12 prints me normaly what is at array[1][0] then array[2][0] then array[3][0] etc … | |
Use a two-dimensional array to solve the following problem. A company has four salespeople (1 to 4) who sell five different products (1 to 5). Once a day, each salesperson passes in a slip for each different type of product sold. Each slip contains the following: a) The salesperson number … | |
Hey i am beginner and i read a book about c++,and i like to do all the exercises alone until i find alone the solution. but one of the topics that give me a hard time is recursions. i am on an exercise with the following code. [CODE]#include <iostream> using … | |
i am beginner that studying c++ i used to use codeblocks but last months i use netbeans, studio express has bad text editor for beginners:P all this time i am using cygwin(always failed) recently i saw on google that with mingw and msys i can compile release and run my … | |
hey,thats my first post,i started recently to have for hobby programming,and i am really interesting to learn. anyway i have a problem i write a program that use some classes objects my problem is probably fundamental but i couldnt find answer on net. i have one header file that i … |