49,760 Topics

Member Avatar for
Member Avatar for warzaru

Hello, after I have friendet my class to "<" operator it dosn't work after i use sort over an vector of class instances it does nothing: class + main : class RAngle{ public: int x,y,l; RAngle(){ } RAngle(int i,int j,int k){ x=i,y=j,l=k; } bool operator<(const RAngle& rhs)const { if(l < …

Member Avatar for Lucaci Andrew
0
323
Member Avatar for oscargrower11

Someone looking at my code today told me that I didn't need to delete a pointer I declared in one place because I didn't create it using the "new" operator and went on to say that you only have to delete them when you use the "new" operator to declare …

Member Avatar for Lucaci Andrew
0
535
Member Avatar for poloblue

Good Afternoon, I'm having problems with the termination of C++ program that deals with else if statements within a while loop. Below is the code that I have so far. while (choice != 'y') { //get the choice cout<<"What is your choice? ('a' to 'd', or 'A' to 'D') =>"<<endl; …

Member Avatar for Lucaci Andrew
0
115
Member Avatar for triumphost

Why does the below crash? My pointer is still alive and is constructed in the main so it should not die until main returns :S I was using this with createthread a while back but my Mingw4.5 never supported it. I just upgraded to 4.7 but now this crashes and …

Member Avatar for triumphost
0
1K
Member Avatar for Dudearoo

I have a problem. im trying to have it(it being this program ive writen), to when i press it, for example w for a piece of code to be preformed. My code is as follows. int loopprocess = 0; int score = 0; int keycomand = getch(); while (loopprocess == …

Member Avatar for Dudearoo
0
352
Member Avatar for MastAvalons

I think there are memory leak in my application, perhaps the problem is in a part of code status = myPubSubSubscribe.Receive(fsReceivedTopic, myBufferSubscribe, myHeader, 0); if (status == PS_ENGINE_UNAVAIL) { printf("Unable to connect to the pubsub engine: %s\n", PSPubSub::Status2String(status)); myBufferPublish.FreeBuffer(); myBufferPublish.~PSBuffer(); myPubSubPublish.~PSPubSub(); myBufferSubscribe.~PSBuffer(); myPubSubSubscribe.~PSPubSub(); return; }

Member Avatar for Topiary
1
208
Member Avatar for Haxifix

So, I wrote this snake game in C++ using SFML 2.0 RC and everything was working perfectly until I tried to implement frame independent movement. I understand how to do it, but I can't seem to make it work with my snake game. If the SCALE define is set to …

Member Avatar for Haxifix
0
257
Member Avatar for triumphost

I have a header file that I include into my main.cpp file. I want to set some flags when this file is included. std::cout.flags(std::ios::boolalpha); I want to set that automatically how can I do this? I tried: #ifdef DEFINES_HPP_INCLUDED std::cout.flags(std::ios::boolalpha); #endif //Gives me the error: //error: 'cout' in namespace 'std' …

Member Avatar for mike_2000_17
0
123
Member Avatar for etsko

Hello, I have a problem with c++ windows form. I read a number of elements from first textbox and from second I have to read a height of these elements (i.e. n=5, heights = 150, 160, 170, 180, 190). I made it first in console app and works perfect, but …

Member Avatar for Oxiegen
0
423
Member Avatar for Albino

struct pieces { string ap, bp, cp, dp, ep, fp, gp, hp, ip, jp, lr, rr, lk, rk, lb, rb, q, k; } b, w; Code 1>c:\users\will\documents\visual studio 2010\projects\chess\chess\pieces.h(3): error C2146: syntax error : missing ';' before identifier 'ap' 1>c:\users\will\documents\visual studio 2010\projects\chess\chess\pieces.h(3): error C4430: missing type specifier - int assumed. …

Member Avatar for Albino
0
275
Member Avatar for triumphost

I'm trying to understand recursion and stack overflows. First, why does this not cause a stack overflow? Is it because the function returns every time and that the stack isn't populated upon each call? void Meh() { } int main() { while (true) Meh(); } Two, What is the difference …

Member Avatar for mike_2000_17
0
105
Member Avatar for Sendy Hipo

erm i learn new thing, its a bad idea to use "using directive" inside a class declaration, because this can leads to ambiguous functions/statements inside the main program. using namespace std; the question is, is it okay to use "using declaration" inside a class declaration? such as : using std::cout; …

Member Avatar for Sendy Hipo
0
449
Member Avatar for nuclear

I need to use forms, widgets etc. in my program which already takes care of creating a window and such. So the question is, would it be okay to use Windows lib to add the needed features, such as a form with a few widgets without any errors, memory leaks …

Member Avatar for Ancient Dragon
0
170
Member Avatar for triumphost

The code below gives me a Narrowing conversion from int to uint32_t: typedef union RGB { uint32_t Color; struct { unsigned char B, G, R, A; }; } *PRGB; inline RGB Rgb(int R, int G, int B) {RGB Result = {((R & 255) << 16) | ((G & 255) << …

Member Avatar for WaltP
0
342
Member Avatar for Rodney J

// The Physics Game.cpp : Defines the entry point for the console application. //Rodney Jenkins #include "stdafx.h" #include <iostream> #include <cstdlib> #include <ctime> #include <cmath> using namespace std; double eqOne_vf(double Vi , double a , double t) { return ( Vi + (a * t) ); } double eqTwo_x(double Vf …

Member Avatar for Schol-R-LEA
0
266
Member Avatar for Marcusflint

Hi, Im new to SDL, when i compile this example program i got these linker errors first defined here .drectve `/manifestdependency:"type='win32' name='Microsoft.VC90.CRT' version='9.0.21022.8' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b'" /DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized [Linker error] undefined reference to `__security_cookie' [Linker error] undefined reference to `_alloca_probe_16' [Linker error] undefined reference to `@__security_check_cookie@4' [Linker error] undefined …

0
130
Member Avatar for khallebal

hi all this is the code in question namespace std { typedef std::basic_string<wchar_t> wstring; }; #endif #if defined(__HAIKU__) namespace std { class wstring : public std::basic_string<char> { public: wstring(const char *t) : std::basic_string<char>(t) { } wstring() { } wstring(const wstring &that) : std::basic_string<char>(that.c_str()) { } wstring(const std::basic_string<char> &that) : std::basic_string<char>(that) …

Member Avatar for khallebal
0
240
Member Avatar for poloblue

Hi, I just to know what code should I use to terminate the program when the user input the character n. Here is the code I have so far

Member Avatar for poloblue
0
108
Member Avatar for nuclear

To be specific I'm trying to implement this into a small game. What I'm thinking of is having a base/default class for derived objects such as player, enemies, tiles and so on and later the derived classes would inherit this base class and add whatever is needed depending on the …

Member Avatar for Despairy
0
194
Member Avatar for myk45

Hello All! I was just wondering if C++ classes could internally be represented in the following way: #include <stdio.h> struct A { int a; void (*ptr) (A *); }; void display(A *ptr) { ptr->a = 2; printf("ptr->a = %d", ptr->a); } int main() { A obj; obj.ptr = display; obj.ptr(&obj); …

Member Avatar for myk45
0
120
Member Avatar for vytenis555

Hello everybody, I'm in need of a bit of help here. I got this C# snippet: public static byte[] StringToByteArray(String hex) { int NumberChars = hex.Length; byte[] bytes = new byte[NumberChars / 2]; for (int i = 0; i < NumberChars; i += 2) bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), …

Member Avatar for Milton Neal
0
245
Member Avatar for existinglady

excuse me but can someone teach me how to get a string with space example : this author i need to get the codes on how to get that thank you

Member Avatar for Lucaci Andrew
0
409
Member Avatar for Sendy Hipo

hi, i read in ebook about overleaded iostream operator for class, but im a bit confused about this one : ostream &operator << (ostream &strm, const FeetInches &obj) { strm << obj.feet << " feet, " << obj.inches << " inches"; return strm; } > Notice the function has two …

Member Avatar for Sendy Hipo
0
212
Member Avatar for atown282

I currently have a running program. All i want to do is be able to shut it down at anypoint by pressing CTRL C. I cannot figure out the code for this command for the life of me. Can someone please help me out? thank you. I am using c++ …

Member Avatar for Lucaci Andrew
1
547
Member Avatar for Dudearoo

**Dudearoo** *Useing Code::Blocks* Hey you guys. ive got a problem, ive got a simple while loop being executed that loops 41 lines of code untill the user types no for example int repeat = 2; while (repeat == 2) { // my code // || Example Code // \/ cout …

Member Avatar for rubberman
0
157
Member Avatar for poloblue

Good Afternoon, I'm new to C++ programming and I have to do a program that deals with strings. Below is the code that I have so far, I have problems in this section of the program Get three lines from the keyboards. Play with string copying, concatenation, and input size …

Member Avatar for m4ster_r0shi
-1
139
Member Avatar for sameerge

Hi I need the answers one of my two questions which were asked by our teacher in class room. Q1. Languagess are system software or application software? Q2. In which software the languages are written? for example in which software the c++ language is written? plz give your answer with …

Member Avatar for WaltP
0
216
Member Avatar for alsz

hi everyone I am having a little problem with the program below. If I input "2/5 * 2/6" the char "/6" will be stored, so when I try to multiply by a simple variable by entering "3/7 * 6" the program will read "3/7 * 6/6". is there a way …

Member Avatar for VernonDozier
0
366
Member Avatar for Taniya19

I want a fast algorithm to calculate no of permutations for n elements with some elements identical. Using formula : n! / k1! k2!....km! where ki = no of i elements, i = (1,2,...m) and k1 + k2 + ...... + km = n **Without calculating each factorial** as if …

Member Avatar for TrustyTony
0
166
Member Avatar for sternone

Hi, I only know C++ as a medium level programmer, not a real beginner but absolutely no veteran, I need to learn so much more C++ stuff. I can fairly program small programs in C++ and i really like C++. I also started using some of the new cool C++11 …

Member Avatar for sternone
0
244

The End.