How do I use CDatabase and CRecordset to return a list of tables in a given database. I am connecting sucessfully to a MySQL server on a unix machine. I know this because I can pass a SELECT * FROM query and get a populated recordset in return.....however when I try "SHOW TABLES FROM db_name" I get an assertion error. Thanks.
JKallen
Posts
-
CDatabase -
Problem Overloading operator new in a template classI am over-riding operator new [] so that when an array of "Objects" is created they contain information about adjacent items in the array. I am getting the following error.... c:\Visual Studio Projects\JLib\main.cpp(149): error C2661: 'Object::operator new[]' : no overloaded function takes 3 arguments The following code results in the above comilation error. Object* objects; objects = new Object[5]; // <- error occurrs here delete [] objects; If anyone knows what is going on I would very much appreciate an explanation. Here is the relevant declarations and definitions... #pragma once #include using namespace std; template class Object{ public: //CONSTRUCTORS ETC ETC ETC void* operator new[](size_t size) throw(bad_alloc); void* operator new[](size_t size,const nothrow_t&) throw(); void operator delete[](void* ptr) throw(); void operator delete[](void* ptr,const nothrow_t&) throw(); //OTHER STUF }; template void* Object::operator new[](size_t size) throw(bad_alloc){ Object* data = 0; if ( (data = ::operator new[](size){ //ommitted for brevity } return data; } template void* Object::operator new[](size_t size,const nothrow_t&) throw(){ Object* data = 0; if ( (data = ::operator new[](size,const nothrow_t&)) ){ //ommitted for brevity } return data; } template void Object::operator delete[](void* ptr) throw(){ ::operator delete [] (ptr); ptr = 0; } template void Object::operator delete[](void* ptr,const nothrow_t&) throw(){ ::operator delete [] (ptr,const nothrow_t&); ptr = 0; }
-
Problem overriding operator new [modified]The only difference between your use of the new operator and mine (using your class) is... Your version: A* objects; objects = new A [5]; delete [] objects; return 0; My version: A* objects; objects = new A [5]; delete [] objects; return 0; I dont understand how your code can work without the template type being defined.
-
Problem overriding operator new [modified]I need to define an implementatino of the [] version because the instances of Object have data regarding adjacent instantiations when created via new [] . At least logically they do, so it makes sense to set those relationships in the new construction.
-
Problem overriding operator new [modified]I am over-riding operator new []. I am getting the following error.... c:\Visual Studio Projects\JLib\main.cpp(149): error C2661: 'Object::operator new[]' : no overloaded function takes 3 arguments The following code results in the above comilation error. Object* objects; objects = new Object[5]; // <- error occurrs here delete [] objects; If anyone knows what is going on I would very much appreciate an explanation. Here is the relevant declarations and definitions... #pragma once #include using namespace std; template class Object{ public: //CONSTRUCTORS ETC ETC ETC void* operator new[](size_t size) throw(bad_alloc); void* operator new[](size_t size,const nothrow_t&) throw(); void operator delete[](void* ptr) throw(); void operator delete[](void* ptr,const nothrow_t&) throw(); //OTHER STUF }; template void* Object::operator new[](size_t size) throw(bad_alloc){ Object* data = 0; if ( (data = ::operator new[](size){ //ommitted for brevity } return data; } template void* Object::operator new[](size_t size,const nothrow_t&) throw(){ Object* data = 0; if ( (data = ::operator new[](size,const nothrow_t&)) ){ //ommitted for brevity } return data; } template void Object::operator delete[](void* ptr) throw(){ ::operator delete [] (ptr); ptr = 0; } template void Object::operator delete[](void* ptr,const nothrow_t&) throw(){ ::operator delete [] (ptr,const nothrow_t&); ptr = 0; }
-
Template Overloading of Non-Mrember Operator [modified]I am trying to overload an assignment operator that that assigns an underlying type with the the assignment operator of the template's underlying class. It should be much simpler than creating the syntax of my opening sentence. If anyone can tell me what the hell im doing wrong I would be much obliged. template T& operator=(T& t,const Object& object); template class Object{ friend T& operator=(T& t,const Object& object); public: Object(); //ommitted for brevity protected: Object* m_daddy; T m_data; }; //----------------------------------FOLLOWING IS THE CPP FILE #include "StdAfx.h" #include ".\table.h" template T& operator=(T& t,const Object& object){ t = object.m_data; return t; } template Object::Object(){ //the constructor stuff goes here } I GET THE FOLLOWING ERROR c:\Visual Studio Projects\Statistician Pro\Table.h(5): error C2801: 'operator =' must be a non-static member
-
Templates and protected members [modified]Actually you are correct. This was a bad example. I am trying to not copy and paste all the code becasue it is complex. The long and short of it is, forgetting the parameter mistype in the function declaration and defintion, the question is "can templates with different basic underlying types access each others protected members assuming the protected member type is independant of the underlying base type?" A simple analgoy is a list object. you have the following protected members; T* m_data; int m_length; All lists have the m_length variable to manage the m_data variable. I would think there is a way to get an object of type List and List to access each other's m_length variable directly. I recognize that a public function can return this but lets say for arguments sake I dont want to create the function to return length.
-
Templates and protected members [modified]OK Here goes.... Here is a useless example in real life, but this is a simplified example of where I am getting a compiler error. template class MyClass{ public: //.....................public members and functions virtual bool copy_whatever_I_can(const MyClass& object); protected: int m_int; T m_data }; template virtual bool MyClass::copy_whatever_I_can(const MyClass& the_char){ m_int = the_char.m_int; //all objects of MyClass have the m_int variable return true; } MyClass my_ints; MyClass my_chars; my_ints.copy_whatever_I_can(my_chars); //<----this causes the cannot access protected member error
-
Templates and protected members [modified]I have been programming for years and have managed to not have to get to involved with implementing my own templates classes, so the following probably has a simple solution. If I have declared and defined the following template class.... template class MyClass{ public: //.....................public members and functions protected: int m_int; T m_data }; MyClass my_ints; MyClass my_chars; The my_ints instantiation cannot access the my_char.m_int protected member variable even though that member variable is of the same type regardless of the underlying type the template encapsulates. This should have a simple solution. Thanks. JK
-
Quicksort algorithm is Causing stack overflow [modified]So. Is the message you cannot sort more than 3000 items using a quick sort algorithm? Is there a way around this limitation? ie is there a way to manage the recursive calls dynamically?
-
Quicksort algorithm is Causing stack overflow [modified]It is legal. It is only redundant on a per compiler basis. long signed int specifies for all compilers where some platforms may default to short as the old C++ compilers do,..etc. the definition is fine. in fact I changed the "ints" to short signed unsigned lnog etc,...no difference. The problem is that I am running out of stack,...what i dont get is why this happenes sorting 3000 items.
-
Quicksort algorithm is Causing stack overflow [modified]Ok. Why would that happen after a sort size of 3000 for instance????
-
Quicksort algorithm is Causing stack overflow [modified]I do not understand why this is happening, however the following functions work for small numbers of data, but for larger numbers (ie 100,000 to 1,000,000) I get a stack overflow. These are protected functions of the class "Sample." Sample has a one dimensional dynamically allocated array of doubles pointed to by the m_data variable. Any help would be appreciated because I have not been able to find a solution to this Thanks
void Sample::quicksort(signed long int top, signed long int bottom){ signed int long middle; if (top < bottom){ middle = partition(top, bottom); quicksort(top, middle); quicksort(middle+1, bottom); } return; } signed long int Sample::partition(signed long int top, signed long int bottom){ double x = *(m_data + top); signed long int i = top - 1; signed long int j = bottom + 1; double temp; do{ do{ j--; }while (x > *(m_data+j)); do{ i++; }while (x < *(m_data+i)); if (i < j){ temp = *(m_data+i); *(m_data+i) = *(m_data+j); *(m_data+j) = temp; } }while (i < j); return j; // returns middle index }
-
CMonthCalCtrl Rendering Problem [modified]I am using an instance of the CMonthCalCtrl class. However when I executed the application and click on the a specific date, the date disappears and in some cases half of a rectangled border develope around the normally oval blue date. When I use the CDateTimeCtrl class (with the calendar functionality) this does not happen. I believe this is simply a redraw error because when I click forward a month the selected date redraws properly. Any ideas? I am using Visual Studio 2003 and I am running XP Multimedia. I am using a digital widescreen flat panel display (24") which occaisionally has problems properly rendering borders on objects on web pages. -- modified at 19:45 Saturday 5th August, 2006 When I rotate my monitor 90 degrees the control renders properly (as do the webpages that exhibit the rendering problem mentioned above).
-
office look not supported in VC .NET 2005I have been wondering the same thing. I am using 2003 and use C++ and have given up on getting the new office 2003 look. I have a lot of respect for you. I thought I was a nerd, I started it all when I was 18. (I had a girlfried though so iwas not allowed to have "Fun." Cheers (From America)
-
Visual Studio QuestionI used to use Borland's IDE and they had a cool tool called an object browser (I think) which was analagous to an object-oriented pedigree. It is essentially an image of boxes representing classes and lines representing relationships (vis inheritance). I find it a much simpler way to visualize complex inheritance than the object browser included in MS's product. If there an add-in or this facility built in which I have just not discovered yet? Thanks.
-
Simple Question regarding Pointer ArithmeticI am writing a template container class similar to a vector or list. I am optimizing the class for performance not size. I want to know between the two examples relatively speaking how much faster example 2 is than 1. Since the functionality employed within the loops is simple, it stands to reason the conditional testing (in the while clause) is relatively speaking measureable (from a performance standpoint......as compared to a loop where complex assignments are occurring. Example 1: T* dst1; //is pointing to legitimate memory address. T* src1; //is pointing to legitimate memory address. T* dst2; //is pointing to legitimate memory address. T* src2; //is pointing to legitimate memory address. T* stop = dst1 - 1000000; //is pointing to legitimate memory address as part of the same array dst points to. while (dst1-- > stop){ *dst1 = *--src1; } stop = dst2 - 1000000; while (dptr2-- > stop){ *dst2= *--src2; } Example 2: T* dst1; //is pointing to legitimate memory address. T* src1; //is pointing to legitimate memory address. T* dst2; //is pointing to legitimate memory address. T* src2; //is pointing to legitimate memory address. T* stop = dst1 - 1000000; //is pointing to legitimate memory address as part of the same array dst points to. while (dst1-- > stop){ *dst1= *--src1; *--dst2= *--src2; } Obviously 2 is faster, but by how much?? In other words compared to the increment operations dereferencing and assigning of memory addresses, how much does the 1000000 conditional tests affect performance compared to the 1000000 of each operations occurring in the loop. Thanks
-
mySQL 4.0 vs mySQL 5.0I am running mySQL 4x on a FReeBSD dedicated. I am trying to figure out how to install mySQL 5 NOT IN PLACE OF mysql 4. I want to be able to run both versions for testing reasons before I remove the older installation. The standard pkg_add returns an error regarding a conflict with the older version of mysql.
-
Keyboard MappingI have used notpad, wordpad, putty, and SSH terminal login. They all give the same result. Additionally, the left shift key + \ will close a dialog window (much like esc or the SC_CLOSE event),...however the right shift key + \ does not add the carriage return nor does it act as an SC_CLOSE event.
-
Keyboard MappingI am using a friend's computer (MS XP Home) and am trying to do some remote unix programming through it. The following is in regards to the left shift key only. The right shift key works fine. However I dont use the right shift key so that is of little use to me. The long and short of it is the 'Shift+\' should result in '|' which is necessary for creating "or" statements in php and C++. When I hit "Shift+\" I get the pipe symbol "|" plus a carriage return. How do I reset the keyboard programming so that shift+\ yields a pipe "|." I do not have sticky keys, filter keys or toggle keys turned on. Thanks -- modified at 21:22 Monday 21st November, 2005