190 Posted Topics
Hi everyone, I'm trying to write a stored procedure select statement which is a little beyond my experience level. I have a table in the DB called addresses which contains the following fields: [LIST] [*]address, VARCHAR [*]count, INT [*](a few more fields) [/LIST] My stored procedure will take in a … | |
In c++ i want to know how to output the result on dos screen page wise,i.e. when i am displaying something if the page is filled then a prompt should come like "Press any key to continue.." More precisely i want an equivalent of the '/p' command which is used … | |
Today when i woke up and turned on my computer, the XP loading screen (with the three blue blocks always going) stayed like that and never changed. i tried running my comp in start mode, but 2-3 seconds after i see the login screen, my computer restarts. what should i … | |
Re: [QUOTE=Ancient Dragon;631862]You are using a compiler with the world's best debugger. You don't need debug messages. Just compile your program for debug and use the debugger to set breakpoints, see the value of variables and program execution.[/QUOTE] This isn’t entirely true. While the debugger is great for most apps, there … | |
Re: void function(int& aaa[][], int 1d, int 2d) { for(int i=0; i<1d; i++) { for(int j=0; j<2d; j++) { aaa[j] = i*j; } } } This is wrong, for many reasons. First, this is an array of arrays of references. The caller is not going to be able to pass a … | |
Re: [QUOTE=zoner7;621213]My suspicion is that, in the below code, the continue statements effectively do nothing and put my code right before the return false statements.[/QUOTE] No. "continue" skips the remaining iteration of the loop (in this case, the for loop). So it goes directly to the "n++" step, and then starts … | |
Re: [QUOTE=henpecked1;622552]ahhh I see. Now if I wanted to call pedal from cycle, but within bicycle, I think I can do it by just putting cycle::pedal(); in bicycle's member function pedal. Is there another way to do it? (I did this in a door class with a door open member function, … | |
Re: you can compute it by dividing by 100 (removes the last 2 digits) and then mod'ing by 10 (only keeps the last digit) (x / 100) % 10 | |
Re: [QUOTE=faust_g;621576][code=CPP] //vector initialized to allocate 10 string objects vector<string> *pvec1 = new vector<string>(10); delete pvec1;[/code][QUOTE=faust_g;621576] I am not sure what you mean by "allocate 10 string objects". There are no string objects here at all. This is just a special functionality of vectors that reserves enough space to hold 10 … | |
Re: Reflection. you need it when you want to invoke a method by reflection. A method does not have to be public to be invoked. However, you will need to know how to get it. (Class.getMethod() will not work, it only works for public methods; Class.getDeclaredMethod() will work) | |
Re: If there is truly a legitimate reason for a subclass to want to access a field, it should be declared "protected". | |
Re: The standard way to do it with inheritance is probably to have an array of Employee pointers [code]Employee* employees[10];[/code] (You can also dynamically allocate it if you really wish. It will be like [code]Employee** employees = new Employee*[10];[/code] ) and then put whatever employees you want in there [code]employees[0] = … | |
Re: [QUOTE=niek_e;616629]Well.... ok, but just this once ;) Private means that the variable is only accessible [i]inside[/i] the class. Public means it can be accessed by anyone. Here's an example to make things clearer: [code=cpp] class DistSign { private: int priv; public: int publ; void ShowMe(void) { std::cout << "private: " … | |
Re: [QUOTE=Kadence;617161]Is there any programming reason why I always see function definitions with arguments like this: [CODE]char getchar(char *arr){[/CODE] Instead of this?: [CODE]char getchar(char arr[]){[/CODE][/QUOTE] These are identical. It is a pointer in both cases. So I guess it may be more clear to write it as a pointer. The second … | |
Re: [QUOTE=Duoas;613105][code=C++] template<typename T, typename U> void print_first_five( map<T,U> m ) { for (int i = 0; i < (m.size() >= 5) ? 5 : m.size(); i++) cout << m[i].second; } [/code] Hope this helps.[/QUOTE] This is wrong, by the way. "m[i]" looks up "i" as a key in the map. … | |
Re: it's right. vector doesn't have a method named "length()". it does have a method named "size()". | |
Re: [QUOTE=midimatt;607136]what i was thinking was could i just do [code=c++] vertices = new float[v][3]; [/code][/QUOTE] this one only works if the "3" part is a constant, and always creates a "rectangular" array made of contiguous parts, no pointers involved | |
Re: [QUOTE=flash121;606942]Doesn't work :( .[/QUOTE] Next time, at least put in minimal effort and post an error or something; instead of other people repeatedly posting suggestions, and you just saying "doesn't work" each time without any clue as to what doesn't work. | |
Re: how about [code]root = new Node<K>(newKey, NULL, NULL);[/code] | |
Re: Also, a fundamental problem with your grow() function: void grow(int array[], int newnumber, int oldsize) { //... array = temp; // swap contents back to array } The last line is completely useless, because "array" is a local variable, assigning it has no effect outside the function. | |
Re: So these are all very self-explanatory. What part of the errors don't you understand? [QUOTE=kse989;603190]Tree.cpp:95: error: no matching function for call to `TreeType<int>::Find(int&)' bintree.h:235: note: candidates are: void TreeType<ItemType>::Find(ItemType&, bool&) [with ItemType = int][/QUOTE] Apparently Find() takes two arguments (a bool reference as a second argument) and doesn't return anything; … | |
Re: the second and fourth const are utterly and completely pointless. there is never a point to declare that a value passed by value is not going to be modified. you should remove them | |
Re: static local variables and static data members have lifetimes like global variables (there is only one copy in the program, and it exists for the whole duration of the program), except that their scope is not global | |
Re: sum should be set to 0 at the beginning of every iteration of the outer loop and i is only incremented at every block of three, so "bin[i]" is the same all three times | |
Re: [QUOTE=Ancient Dragon;598387]1) when using vectors you can access individual elelements just as you would do with a simple int array [icode]B = LiDARGrid.ConcentricScans.[scancounter].getColumn(concentriccol);[/icode][/QUOTE] except that it doesn't check bounds | |
Re: [QUOTE=henpecked1;597636][code]sphere::sphere() //default constructor { int Radius=0; }[/code][/QUOTE] wow. what did you expect that code to do? | |
Re: [QUOTE=complexcodes;597738][CODE]opOverload obj1 = (10,20); opOverload obj2 = (30,40);[/CODE][/QUOTE] should probably be [CODE]opOverload obj1(10,20); opOverload obj2(30,40);[/CODE] | |
Re: just download it from the sourceforge project [url]http://sourceforge.net/projects/dev-cpp/[/url] | |
Re: you could either get all the digits out into a list or something, and then parse them back into a number in reverse or just take the input as a string and reverse the string | |
Re: you need to make the method in the base class [B]virtual[/B] [url]http://en.wikipedia.org/wiki/Virtual_function[/url] | |
Re: if you need to delete arbitrary elements a lot, then perhaps you don't want to use a vector, because it is very expensive, both to find it and to shift all the remaining elements | |
Re: and why can't you just tell us what is wrong with it? | |
Re: a completely literal translation into C++ would be like this: [CODE]class Node{ private: void *item; Node *next; public: Node(void *obj) : item(obj) { } void *getItem() const { return item; } Node *getNext() const { return next; } void setItem(void *obj) { item = obj; } void setNext(Node *n) { … | |
Re: why don't you post code that actually compiles? | |
Re: start with this [code]bool discr(double array2[3], double &result)[/code] do you know how to use c++ references? | |
Re: [QUOTE=Cosa;592662][code]float* matrixa = new float(6);[/code][/QUOTE] you probably wanted [code]float* matrixa = new float[6];[/code] | |
Re: why don't you post the exception and stack trace, and post the code inside code tags | |
Re: no, it is better that you make the class a functor class (its has an overloaded function call operator); and then you should template the sort function, so it can either take a function pointer or a function object [code=C++] int compare(int a, int b) { return a - b; … | |
Re: The first piece of code works because "mtab" is an [B]statically-sized array[/B] which the compiler knows the size at compile time. (The macro is just a convenient compile-time trick.) The second piece of code doesn't work because "myclass->smath" is a [B]pointer[/B], and there is no way to tell how many … | |
Re: [QUOTE=beatlea;588200]It says 'This will allow to practice with ArrayList and allow you to use generics, if you wish.'[/QUOTE] Well are you using Generics? Maybe you should. [url]http://java.sun.com/j2se/1.5.0/docs/guide/language/generics.html[/url] | |
Re: in java objects are always referred to using "references", which are kind of like pointers in C, except that you can't do silly stuff with them | |
Re: you mean [code]static myClass *getInstance();[/code] | |
Re: You can't really delete an arbitrary item from a priority queue easily; only the item with the highest priority. Maybe you should read up on what priority queues are: [url]http://en.wikipedia.org/wiki/Priority_queue[/url] The items in the priority queue (implemented as a binary heap) have some structure, but are not in sorted order; … | |
Re: [QUOTE=KimJack;584103][code] if(hash.containsKey(hash.get(info)))[/code][/QUOTE] This line makes no sense; you are getting the value that is associated with the key "info", and then you are testing whether that value is a key in the hash table? | |
Re: [QUOTE=jwenting;583932]Nor can you use arrays.[/QUOTE] no | |
Re: [QUOTE=kse989;581988] stream << rear[counter] << " ";[/QUOTE] um... how the hell do you expect this to work? this is a linked list, not an array; you cannot index it like that; you have to traverse the links | |
Re: result is set to 10 in the last iteration of the first for loop and then you assign result (10) to every element of your 2-d array in the other for loops | |
Re: x.multiply(y) why don't you show us what your problems are |
The End.