380 Posted Topics

Member Avatar for Labdabeta

I need a way to do the following and I cannot think of one, this is what I have so far: [CODE]typedef Obj2*(*Reaction)(); class Obj1 { public: Reaction reaction; }; class Obj2 { public: unsigned int numobj1; Obj1 *objects; }; class Obj3:Obj2 {};[/CODE] Can you find any way of doing …

Member Avatar for Labdabeta
0
93
Member Avatar for Labdabeta

How can you play videos in C++, I am quite willing to use more than less any headers, I basically need a code that will work like this: [CODE]#include "PlayVideos.h" int main(int argc, char *argv[]) { SDL_Surface *screen=SDL_SetVideoMode(WINWIDTH,WINHEIGHT,WINBPP,SDL_SWSURFACE); ShowVideo("MyVideo.avi",0,0,screen);//play a video at position 0,0 and apply it to the screen …

Member Avatar for mike_2000_17
0
186
Member Avatar for Labdabeta

I have a problem that I am having trouble solving. I have a string of undefined length containing '0' or '1'. I need to convert this string to decimal... but I CANNOT store it in anything but another string. My issue is how to do this?! I have been thinking …

Member Avatar for nezachem
0
154
Member Avatar for Labdabeta

I am making a diplomacy tool, for the board game diplomacy. I need to make a map of each territory. I have a 75 #define MAP_"NAME" lines but I don't know how to set them to a mask value that can be checked since I don't know any 75-bit or …

Member Avatar for Labdabeta
0
202
Member Avatar for Labdabeta

Hello, I have a few questions about Assembly. I am extremely new to it! Question 1: How do you write functions in assembly? Is it even possible? Question 2: How do you get an input to a dd variable type (do I have to do the math on four db …

Member Avatar for chrjs
0
106
Member Avatar for Labdabeta

If I have a templated storage class, how can I create a specialized template for nested storage class. I already know how to specialize pointer template, but I don't know how to specialize this. EG: [CODE]template <typename Type> class Array { ///Array class code }; int main() { Array<int> rob; …

Member Avatar for Narue
0
140
Member Avatar for hous3aholik

This is not too hard as far as I can tell. Your post is a little vague, but I think that you should just store the random number in a variable and check it against all the elements of your array.

Member Avatar for VernonDozier
0
195
Member Avatar for Labdabeta

Is there any way to implement a scope change for the template keyword? I have a templated class with almost 100 different functions and my code looks disgusting with my external declarations. Is there any way to implement a scope increase for template? EG: [CODE]template <typename Type> class TypeClass { …

Member Avatar for Fbody
0
204
Member Avatar for Labdabeta

Is it possible to overload an operator for a built-in type? And if so what is it's syntax? EG: [CODE]//Use of overloaded operator^ for types double and double (assuming it is overloaded for exponent): double a=10.0; double b=2.5; double pow=a^b;//pow is approximately 316.22....[/CODE]

Member Avatar for L7Sqr
0
179
Member Avatar for Labdabeta

I am having trouble with a program that I am writing. I cannot seem to be able to destroy a window. I know the DestroyWindow function but it only works on windows that my application owns. Is there any way to destroy a window that is not owned by my …

Member Avatar for Labdabeta
0
126
Member Avatar for Labdabeta

I am having a lot of trouble getting the following to work and I think it is because of file issues: [CODE]int GetMinutes() { fstream file(FNAME); char num[101]; if (!file.is_open()) Error("FILE NOT OPEN!"); file.getline(num,100); file.close(); return atoi(num); } int main(int argc, char *argv[]) { LARGE_INTEGER timestart, timestop, tickspersecond; QueryPerformanceFrequency(&tickspersecond); QueryPerformanceCounter(&timestart); …

Member Avatar for WaltP
0
134
Member Avatar for Labdabeta

I have made a header file with a templated dynamic array class that I wish to convert into secure code. The problem is that since all of the code relies on the Template I cannot put it into a static library. Any ideas how I could still make the source …

Member Avatar for Labdabeta
0
99
Member Avatar for Labdabeta

I have asked this question before on a different forum without success. I would like to know how to do templated type conversions for a class. The syntax is getting me though. Here is what I want: [CODE]class Thing { public: template <typename T> T operator T(); }[/CODE] This would …

Member Avatar for Labdabeta
0
99
Member Avatar for Labdabeta
Member Avatar for Labdabeta
0
447
Member Avatar for Labdabeta

I need a few helps for some things that I just cannot get the syntax of! (I need these, and if you don't believe me I can post the reason) 1) Creating a function within a function 2) Creating a class within a function 3) Declaring a template function outside …

Member Avatar for mike_2000_17
0
149
Member Avatar for mxrider

When passing something to a function as a reference you have to reference it. You are passing a normal double to your bVolume function, but double is not double&

Member Avatar for ravenous
0
146
Member Avatar for Labdabeta

I am making a screensaver and it won't build! The error I get is "undefined reference to '_SDL_main'. Here is my code: [CODE]#include <windows.h> #include <scrnsave.h> BOOL WINAPI ScreenSaverConfigureDialog(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { system("TMXDB.exe"); return true; } BOOL WINAPI RegisterDialogClasses(HANDLE hmodule) { return true; } int …

Member Avatar for Labdabeta
0
263
Member Avatar for Labdabeta

I am working on making a 'safetype' abstract class, which will have a complete set of pure virtual operator overloads to help make sure that a class inherited from it is safe to pass to virtual any function. The problem is that I don't know the syntax of a pure …

Member Avatar for Labdabeta
0
262
Member Avatar for Labdabeta

I am working on making an error header file and this is what I have: [CODE]#include <stdio.h> #include <stdlib.h> #include <iostream> #include <sstream> #include <string> #define VANARGS(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25,n26,n27,n28,n29,n30,n31,n32,n33,n34,n35,n36,n37,n38,n39,n40,n41,n42,n43,n44,n45,n46,n47,n48,n49,n50,n51,n52,n53,n54,n55,n56,n57,n58,n59,n60,n61,n62,n63,N,...) N #define __VA_NARGS__(...) (VANARGS(__VA_ARGS__,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)) #define ERROR(...) (\ (__VA_NARGS__(__VA_ARGS__)==0)?"NONE":(\ (__VA_NARGS__(__VA_ARGS__)==1)?(_1(__VA_ARGS__,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)):(\ (__VA_NARGS__(__VA_ARGS__)==2)?(_2(__VA_ARGS__,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)):(\ (__VA_NARGS__(__VA_ARGS__)==3)?(_3(__VA_ARGS__,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)):(\ (__VA_NARGS__(__VA_ARGS__)==4)?(_4(__VA_ARGS__,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)):(\ (__VA_NARGS__(__VA_ARGS__)==5)?(_5(__VA_ARGS__,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)):(\ (__VA_NARGS__(__VA_ARGS__)==6)?(_6(__VA_ARGS__,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)):(\ (__VA_NARGS__(__VA_ARGS__)==7)?(_7(__VA_ARGS__,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)):(\ (__VA_NARGS__(__VA_ARGS__)==8)?(_8(__VA_ARGS__,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)):(\ (__VA_NARGS__(__VA_ARGS__)==9)?(_9(__VA_ARGS__,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)):(\ (__VA_NARGS__(__VA_ARGS__)==10)?(_10(__VA_ARGS__,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)):(\ (__VA_NARGS__(__VA_ARGS__)==11)?(_11(__VA_ARGS__,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)):(\ (__VA_NARGS__(__VA_ARGS__)==12)?(_12(__VA_ARGS__,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)):(\ (__VA_NARGS__(__VA_ARGS__)==13)?(_13(__VA_ARGS__,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)):(\ (__VA_NARGS__(__VA_ARGS__)==14)?(_14(__VA_ARGS__,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)):(\ (__VA_NARGS__(__VA_ARGS__)==15)?(_15(__VA_ARGS__,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)):(\ …

Member Avatar for Labdabeta
0
261
Member Avatar for w1mark

Well, here is what I would basically do, it takes advantage of some of the methods that std::string contains: [CODE]string *BreakUp(string in, int *num)//This translates a command into an array of strings, num will become the length of said array { int numWords=0;//This is the number of words in the …

Member Avatar for w1mark
0
539
Member Avatar for Labdabeta

I made a header file to convert strings to numbers of base X. That is I want: [CODE]int num=B<16,int>("FFF");[/CODE] To equal: [CODE]int num=0xFFF;[/CODE] Here is the code so far: [CODE]#include <string> int numb(char in) { if (in>='0'&&in<='9') return in-'0'; else if (in>='a'&&in<='z') return in-'a'; else if (in>='A'&&in<='Z') return in-'A'; } …

Member Avatar for Labdabeta
0
140
Member Avatar for user543820

You may want to look at using the substr method and the find method for std::strings to help break strings apart.

Member Avatar for Ancient Dragon
0
173
Member Avatar for Labdabeta

Hello, I have decided to make a timer program on my computer to limit the amount of time that I game. Anyways, I have it working fine with a small borderless window in the top left of the screen that ticks down and when it gets to 0 it sounds …

Member Avatar for Labdabeta
0
7K
Member Avatar for TheWolverine

The problem is that friend methods don't get passed down to inherited classes. Here is an illustration of what I mean: Won't work, friend method does not get passed down: [CODE]#include <iostream> using namespace std; class Base { public: friend void out(){cout<<"BASE";} }; class Derived:public Base {}; int main() { …

Member Avatar for TheWolverine
0
353
Member Avatar for determine

You have to include windows.h, then system("pause") or system("PAUSE") will work fine. Here is a simple code I wrote to display the fact: [CODE]#include <windows.h> int main() { system("PAUSE"); return 0; } [/CODE] Also although it is generally best to avoid OS specificity and keep C++ platform independant, sometimes it …

Member Avatar for determine
0
4K
Member Avatar for determine

The precision function could be useful here: [CODE]cout.precision(2); cout<<2.234134<<endl; cout<<2.343144<<endl;[/CODE] Outputs: 2.2 2.3 In other words, using cout.precision(X) sets the precision of cout to X and it stays that way until cout.precision(Y) is called, then the precision is set to Y. Alse try to avoid using system("pause"), try using cin.get() …

Member Avatar for determine
0
141
Member Avatar for Labdabeta

I have made a header file for SDL GUI applications. I was testing the SDLGame::Draw() function when I got a SigSegV fault. The fault occurs in different locations each time I run the program. Also sometimes instead of a SigSegV fault I get a SigTrap fault. Here is the code …

Member Avatar for Labdabeta
0
881
Member Avatar for caut_baia

Not sure if this is what you are looking for but whenever I have a class that I wish to write to a file I just overload the '<<' operator, then I can do it specially for each object and string them together like: [CODE]fstream file("MyFile.txt", ios_base::in|ios_base::out); file<<MyClass()<<MyOtherClass()<<AnotherMyClass()<<2<<"BOB"<<endl; And it …

Member Avatar for Labdabeta
0
653
Member Avatar for stompjrkz400

If you still wish to do all the outputs and inputs on the same line, the '\b' character might work. You could possibly use it to delete the newline character. Just a thought. One way I know for sure works though is using the Windows.h SetConsoleCursorPosition(). See: [url]http://www.adrianxw.dk/SoftwareSite/index.html[/url] Or you …

Member Avatar for Labdabeta
0
284
Member Avatar for wingmark

I went through all of learncpp.com's tutorials, they were great and tackle almost everything syntax wise. I am now working with Lazy Foo's tutorials for SDL GUI applications: [url]http://www.learncpp.com/[/url] [url]http://lazyfoo.net/SDL_tutorials/index.php[/url] Hope these help :)

Member Avatar for Labdabeta
0
111

The End.