• What do you need help with? V. 3.0
    4,884 replies, posted
[QUOTE=Map in a box;32150928]Not the way he said it. [/QUOTE] [QUOTE=RP.;32150531]When performance is not an issue...[/QUOTE] [editline]6th September 2011[/editline] No offense, but that's a pretty gigantic oversight. Mostly because someone called you out, and you still held on to your idea. The first person you should check for errors is yourself.
[QUOTE=RyanDv3;32150991][editline]6th September 2011[/editline] No offense, but that's a pretty gigantic oversight. Mostly because someone called you out, and you still held on to your idea. The first person you should check for errors is yourself.[/QUOTE] I did v:v:v Whatever, though.
With C++ inheritance can you do anything like Base.Method(); ?
Yes. If your base class is called Base then Base::Method();.
So in this case: [cpp]class BaseManager : public Drawable { sf::RenderTarget* target; public: BaseManager(); virtual ~BaseManager(); virtual void Update(); virtual void Draw(); };[/cpp] inside BaseManager::Update() I would want to do Drawable::Update()
-snip- got it working
-snip- not thinking
I am going insane here, my accessor function returns an uninitialized value but accessing the variable directly returns the correct one, this is definitely going to be one of those DUH moments but I need a fresh pair of eyes to look at it: Variable declaration: [cpp] class BaseEntity : public BaseObject { private: BaseEntity(const BaseEntity&); BaseEntity& operator=(const BaseEntity&); RenderType mRenderType; BaseRender* mRender; //protected: float mAngularVelocity; float mAngularAcceleration; Vector2 mVelocity; Vector2 mAcceleration; [/cpp] Function declaration: [cpp] void SetAngularVelocity(float angvel) {mAngularVelocity = angvel;}; float GetAngularVelocity() {return mAngularVelocity;}; [/cpp] Code: [cpp] BaseEntity::BaseEntity(void) { float mAngle = 0.f; float mAngularAcceleration = 0.f; float mAngularVelocity = 0.f; mIsRenderable = false; std::cout << GetAngularVelocity() << "ang\n"; std::cout << mAngularVelocity << "\n"; } [/cpp] It outputs gibberish in GetAngularVelocity() and outputs 0 when accessing angular velocity directly. OH GOOD GOD. Why would I redeclare the variable...
[QUOTE=conman420;32170964]OH GOOD GOD. Why would I redeclare the variable...[/QUOTE] Well, you made me smile for the first time today, considering I feel dead and slightly scared considering I slept for 21 hours.
[code]#include<iostream> using namespace std; int main(){ double fahrenheit; int celsius = 33; char const* status; cout << "*Celsius to Fahrenheight Converter*" << endl; while (status != "exit"){ cout << "Enter Celsius temperature: "; cin >> celsius; cout << celsius << endl; fahrenheit = (celsius * 1.8) + 32; cout << celsius << " celsius in fahrenheit is " << fahrenheit << endl; cout << "Type 'exit' to close this program or press any key followed by the Enter key to convert another temperature" << endl; cin >> status; } return 0; }[/code] Line 20: error: no match for 'operator>>' in 'std::cin >> status' ?
[QUOTE=Krzystylez;32179595][code]#include<iostream> using namespace std; int main(){ double fahrenheit; int celsius = 33; char const* status; cout << "*Celsius to Fahrenheight Converter*" << endl; while (status != "exit"){ cout << "Enter Celsius temperature: "; cin >> celsius; cout << celsius << endl; fahrenheit = (celsius * 1.8) + 32; cout << celsius << " celsius in fahrenheit is " << fahrenheit << endl; cout << "Type 'exit' to close this program or press any key followed by the Enter key to convert another temperature" << endl; cin >> status; } return 0; }[/code] Line 20: error: no match for 'operator>>' in 'std::cin >> status' ?[/QUOTE] Just make status either an std::string or make it an array. In this case you haven't even allocated any memory for it. [editline]8th September 2011[/editline] Preferably std::string.
[QUOTE=Krzystylez;32179595] char const* status; [/QUOTE] Status doesn't point to anything.
[QUOTE=Asgard;32181626]Status doesn't point to anything.[/QUOTE] Ah, indeed! You probably have to initialize a constant pointer.
[QUOTE=Krzystylez;32179595][code]#include<iostream> using namespace std; int main(){ double fahrenheit; int celsius = 33; char const* status; cout << "*Celsius to Fahrenheight Converter*" << endl; while (status != "exit"){ cout << "Enter Celsius temperature: "; cin >> celsius; cout << celsius << endl; fahrenheit = (celsius * 1.8) + 32; cout << celsius << " celsius in fahrenheit is " << fahrenheit << endl; cout << "Type 'exit' to close this program or press any key followed by the Enter key to convert another temperature" << endl; cin >> status; } return 0; }[/code] Line 20: error: no match for 'operator>>' in 'std::cin >> status' ?[/QUOTE] A little hint for you. A constant cannot be changed once defined, and must be defined upon initialization. At least, I'm pretty sure that's it for your case.
anyone here having experience with 2d verlet collision response? everything works quite good except when an object moves over an edge and it should tilt but it doesn't until it can actually fall down. I can't think of a way to combat this without making the whole system jitter around... I couldn't find anything useful with google as I already implemented most of those ideas.
[QUOTE=T3hGamerDK;32181911]A little hint for you. A constant cannot be changed once defined, and must be defined upon initialization. At least, I'm pretty sure that's it for your case.[/QUOTE] Though his problem is that he has an pointer without memory allocated for it. If he would initialize the char const* with something like new char[100], it would work. Note that the const is after the type, that means that it's the variable that contains the address to the memory that is const, not the stuff stores in memory itself. I have a problem with OpenGL. It shows a cube fine like I had depth testing on. But when I turn it on explicitly, it won't show anything at all. [editline]1:11[/editline] Fixed it.
I'm attempting to use OpenCL (Read Open[b][i]CL[/b][/i], not GL), probably to create a particle system or something. It was all going relatively smoothly until I got to this part: [cpp]size_t sizeInBytes; clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, nullptr, &sizeInBytes); cl_device_id *devices = new cl_device_id[sizeInBytes / sizeof(cl_device_id)]; clGetContextInfo(context, CL_CONTEXT_DEVICES, sizeInBytes, devices, nullptr);[/cpp] sizeInBytes is being set to 3435973836, and since cl_device_id is 4 bytes in size that means I'm trying to allocate about 820MB of memory... which seems to be failing with std::bad_alloc. I have no idea what I'm supposed to do about this, any ideas? I'm not sure how many people here have used OpenCL though...
Does clGetContextInfo return CL_SUCCESS?
How could he know when he's discarding the return value :v:
Well, hopefully he's able to change the code.
Oops, forgot I could check stuff like that :v: I'll fix it up in a second and tell you what happens :P
Hopefully you guys can help me with this C++ problem I'm having. I'm trying to create an all in one utility wrapper so to speak to back up an assload of Windows 7 computers. They want it to use WBAdmin due to the lack of having to install excess software and it creates nice VHDs. Here's my problem: (I have full administrator rights) I can run WBAdmin just fine from a command prompt and from a bat/cmd file. However, when I try to run it from my program, it will fail saying "File not found": [code] ProcessStartInfo^ backup7 = gcnew ProcessStartInfo("cmd.exe"); backup7->Arguments = "/k C:\\Windows\\System32\\wbadmin.exe"; Process::Start(backup7); [/code] I've also tried: [code] ProcessStartInfo^ backup7 = gcnew ProcessStartInfo("wbadmin.exe"); backup7->Arguments = "WB Args here"; Process::Start(backup7); [/code] Not only that, but running the batch file via this method causes it to fail: (WBLoader is in the same directory as my exe) [code] ProcessStartInfo^ backup7 = gcnew ProcessStartInfo("cmd.exe"); backup7->Arguments = "WBLoader.bat"; Process::Start(backup7); [/code] Oh, and using the Bat to EXE converter also fails. The resulting EXE also spits out a file now found error. Also I've tried putting my EXE in the System32 directory where WBAdmin is, and it STILL doesn't work. Every other external program I've tried to run this way has worked, but not this one. Does anyone have any ideas?
[QUOTE=thf;32182081]If he would initialize the char const* with something like new char[100], it would work. Note that the const is after the type, that means that it's the variable that contains the address to the memory that is const, not the stuff stores in memory itself.[/QUOTE] No, it's the other way around. "char const *" is a non-constant pointer to constant char; "const char *" is a synonym (and a special case of the "const" being to the left, rather than the right, of the thing it modifies). A constant pointer to non-constant char is "char * const".
Const is such a confusing keyword.
[QUOTE=KillerJaguar;32192725]Const is such a confusing keyword.[/QUOTE] No it's not. It just says that the thing to the left of it (or to the right of it if it's at the start) is constant and isn't to be changed.
How does one use multidimensional arraylists in Java? It really is confusing as fuck, normal multidimensional arrays works just fine, but not this. How exactly do you add value to the arraylist when it's multidimensional? Because all I'm getting when I am trying to add it with a loop is ArrayIndexOutOfBounds. [code] ArrayList<ArrayList<String>> toparr = new ArrayList<ArrayList<String>>(); for(int i = 0; i < 10; i++) { toparr.add(new ArrayList<String>()); } String a = toparr.get(0).get(0); System.out.println(a); [/code]
there are no strings inside any of the sub-ArrayLists.
[QUOTE=robmaister12;32193470]there are no strings inside any of the sub-ArrayLists.[/QUOTE] It should still print out nothing.
[QUOTE=IAmAnooB;32193519]It should still print out nothing.[/QUOTE] try making a single ArrayList<String>, then without adding anything calling get(0); It's the same thing as adding 2 strings to the list and calling get(25); [editline]9th September 2011[/editline] in other words... if (!toparr.isEmpty() && !toparr.get(0).isEmpty()) [editline]9th September 2011[/editline] and if you're wondering why it acts like that, String is an object, and it doesn't return "", it returns null. [editline]9th September 2011[/editline] or rather position 0 of the array is null, so it throws an exception
I have a question about win32(c++) You create a window.. everything is ok. But when you press the 'X' in the right upper corner and the window will close. Is there some way to prevent closing the window?
Sorry, you need to Log In to post a reply to this thread.