- Strength to Increase Rep
- +8
- Strength to Decrease Rep
- -2
- Upvotes Received
- 25
- Posts with Upvotes
- 24
- Upvoting Members
- 17
- Downvotes Received
- 1
- Posts with Downvotes
- 1
- Downvoting Members
- 1
69 Posted Topics
Re: [QUOTE=sjcomp;1148820]Hello, I am using a singleton pattern, which works fine. But when I decided to have a singleton of a nested class that is privately declared. [CODE]class A : public CSingletonTmpl<A> { class B : public CSingletonTmpl<B> { }; }; A* CSingletonTmpl<A>::s_Singleton = NULL; A::B* CSingletonTmpl<A::B>::s_Singleton = NULL; [/CODE] The … | |
Re: [QUOTE=shrutinr;1186620]Hi , I m doing my project in vc++.. I need to interact my vc++ project with NI MAX software.. I m taking Frame API for ineracting to UPS . I included "nican.h" header file for that. I didnt missed any brackets... but while executing i m getting error like … | |
Re: No. This will increment the pointer first and then deference the result. You would require paretheses here to achieve the result you want. [CODE](*size)++[/CODE] This is because unary unary operators like ++ associate right to left.. Also you have a problem in that the expression [CODE]int *size = n; [/CODE] … | |
Re: [QUOTE=blackmagic01021;1198621]I have a void type array. I want to create a function which will read 12 bits in each time and store it in a unsigned int type variable. Any ideas? Thank you.[/QUOTE] So you wish to extract the first 12 bits from each element in your void array? How, … | |
Re: ~077 is the unary of the octal value 77; octal 77 will correspond to the low order 6 bits being set of a word. In 32 bit hex word 0x0000003f. the unary of this flips all the set bits to 0 and all 0 bits to 1 giving 0xffffffc0 this … | |
Re: I'm missing something here. Can you post a compilable example? | |
Re: >> will read to the next whitespace. ie. space character so it wont pick up your space. Do you have to use space? You can explicitly read the next char from the stream though. Check out the other stream functions available to you. Is there anything else you could use. | |
Re: I'm not sure I fully understand your question here. Could we see some code. Just pare down some example classes to the bare minimum required to illustrate what your question is asking and post them. | |
Re: Dictionaries are generally represented by a form of Map as mentioned in previous posts. your solution will wind up with you having many thousands of distinct objects, one for each word entered. this seems to me to be a bit messy. Try reading up on Maps before moving on... | |
Re: why is your definition of vectPointer in your header file? | |
Re: This will likely be a duff pointer. Check your pointers... | |
Re: add the scores together and divide by three. Or if you have n values to average add em together and divide by n. | |
Re: Is that what HKEY_CURRENT_USER is defined to? I'm not going to check for you but I suspec that it is. You would need to provide some method of producing a textual representation of this defined value and printing that instead of the value itself. | |
Re: [QUOTE=daviddoria;1183663] [code] queue a; a.push(1); a.push(2); a.push(2); a.push(3); [/code] to only have 3 elements, because 2 was added twice so the second time it is just ignored. [/QUOTE] But you want this to have FIFO behaviour? Why not create your own queue class, based on a deque for instance, which … | |
Re: I doubt that this will even compile as it stands. You have no return from your longWords function. As for converting a function from an array to a pointer it should not make too much of a difference. When you pass an array argument as a pointer you are passing … | |
Re: or if you wish to read the data items one at a time [CODE] ifstream openFile( "Data.txt" ); float temp; while( openFile >> temp ) { ... }[/CODE] When you write [CODE]openFile >> temp[/CODE] the return value of the input statement is the class object from which you are reading … | |
Re: [QUOTE=shilpa.joshiv@g;1182773]hi,,, i have converted the image in to gray and created itz histogram...nw i m applying various filters on the gray image...my problem is: 1.. want to display the result image after filtering in dialog box... for this i have created the dialog class...but not getting how to send the … | |
Re: Traditionally a dictionary would be represented as a Map. Where the word would act as the key value into the map and the definition would correspond to the value for that key. Maybe you could produce a map for language conversion where the key value is a word in the … | |
Re: [QUOTE=deanus;1181033]Hi I've just started out in c++, can anyone tell me how to use pointers which hold addresses of objects ? How do you access the object fields from this type of pointer, especially strings (array of chars)... I'm using a Dev c++ 4.9.9.2 compiler....[/QUOTE] you might want to post … | |
Re: SESE (single entry single exit) was quite a big thing at one point, more especially in C as it was felt that it made functions easier to maintain amongst other things. In C++ where you have exceptions as another way in which a function can be exited it is difficult … | |
Re: Depends how much you want to increase it by. Simply declare it in a lerger scope. instead of [CODE]MyClass *stable; if(..){ MyClass temp; stable=&temp; } stable.myVariable;[/CODE] try [CODE]MyClass *stable; MyClass temp; if(..){ stable=&temp; } stable.myVariable;[/CODE] if you really don't want temp hanging around any longer that necessary then enclise it … | |
Re: [QUOTE=myluvstefan;1177841]Hi, I've spent a lot of time on this program and I'm stuck. My assignment is to prompt for two input strings. Print out each string Concatenate string1 and string2 and store the concatenated string into string3 without changing what's stored in string1 or string2. print out the concatenated string. … | |
Re: [QUOTE=LemonLemon;1180716]I am using VC++ 2008. I want to rotate the Bitmap in my MFC application. I tried the GetPixel and SetPixel functions, but the performance is too slow. There seems no Bitmap rotation example using MFC class on the internet Can anyone give me some idea? Sample code will be … | |
Re: you need to declare stream objects of type ifstream. eg. [CODE] ifstream inputfile; inputfile.open(filename);[/CODE] ifstream is a class definition, not a concrete object which you can use. You have to declare an instance of the class to use it. Looking again I see you have done so in you main. … | |
Re: If your code is as posted then the only problem I can see is the extra ',' in you function prototype. [CODE]void Find(uint4& a, uint4 b, uint4 c[B][I],[/I][/B]);[/CODE] | |
Re: > This is likely a stupid question, but I can't figured out by myself how to pass a pointer to a member function of a templatised class in its own template parameters. > More clearly: > I would like to have this to work out: template <typename T, T test::* … | |
Re: As I have told you in one of your numerous other posts on this subject you need to get hold of an introductory programming text and read the first couple of chapters. You are lacking in some really fundamental concepts here, how to declare and use variables, how to declare … | |
Re: [QUOTE=rkp728;1175860]I want to fill a structure and then print it. How to print the values of the structue? The structure is: [CODE] #define UINT32 unsigned int #define INT32 int #define UCHAR unsigned char typedef struct CheckSumPair { UINT32 weakcs; // The weak, rolling Adler32 checksum. UCHAR StrongCS[10]; };[/CODE] I have … | |
Re: Same problem with default arguments as your other post. | |
Re: Default arguments should be at the right of the declaration. eg. [CODE]int func( int x, int y = 1, int z = 2 );[/CODE] you cannot have variables which do not have a default definition on the right hand side of those that do. [CODE]int func( int x = 1, … | |
Re: You should also be aware that your class will require a copy assignment operator and also a destructor to properly handle your dynamic array. Do a search for the 'rule of three' for details on this. Also do a search of Marshal Clines C++ faq lite (google for it) for … | |
Re: [I][/I][QUOTE=tetron;1169267]const is a some what overrated concept that leads to more typing and maintenance. In your case myfunc is not const as it alters a member variable if this is not appropriate to be altered then you need to use a local [CODE] double myfunc(double x1,double x2, double x3) const … | |
Re: I wonder what you are expecting to see? I haven't had much need to use the typeid operator to date so I have had fun fiddling around with this. The exception you see indicates that you are attempting to use typeid on an expression that equates to an invalid object. … | |
Re: [QUOTE=Banfa;1168109]You seem to be treating as a single step, get the return value of a function, what is actually 2 steps [list=1]Return a value from a function [*]Assign that value to a variable [/list] Both have associated efficiencies as follows [b]Return a value from a function[/b] [list]Return by value - … | |
Re: You already have two very good books. Try reading the C++ primer for an introduction to the language, and don't be fooled that it doesn't cover what the C++ programming language covers as it will cover all language features. Then when more comfortable with the language use the cpppl for … | |
Re: Marhsal Clines C++ FAQ Lite has a nice section on object serialization covering various options open to you. This is a very good place to start. [URL="http://www.parashift.com/c++-faq-lite/serialization.html"]http://www.parashift.com/c++-faq-lite/serialization.html[/URL] | |
Re: If this is your exact code then [I]to begin with[/I] you should look for missing semi colons. I wonder what you are using to compile this?!? | |
Re: Both of the previous responses to this question were incorrect. The code snippet you see here is perfectly valid and is an idiom oft used by the STL. The struct g represents a function object, or functor. It overloads the function call operator, that is its purpose. What this means … | |
Re: What is the signature of this function? glColor3f is this a function you have specified yourself? If so it seems as though the function is expecting an int where you have provided an array. Did you forget a '*'? | |
Re: You are assigning pointers not objects. | |
Re: Both would work, but my view here is that both classes should provide the overloaded operator. Obviously these classes are contrived, in a real world example the method of only providing the overload in the one class could very quickly get messy if the contained classes were complex. | |
Re: What you are discussing here is termed serialization, or sometimes object persistence. Boost contains an excellent library which will handle all of this for you and is worth researching. Serialization is a non-trivial exercise with some interesting design choices which have to be made before selecting an implementation. Check out … | |
Re: your code is not organized correctly. Although it is traditional to organize definitions into header files and implementation into .cpp files this will not work effectively for tempates. As you have found a compiler will generally accept this but it will not ge by the linker. The reason for this … | |
Re: by doing a comparison for 'q' you are comparing a string to a char which is not supported. first thing to try "q"... then maybe more errors may become apparent... | |
I am curious about how to post or have published tutorials. I have searched the forum but the latest information I cna find is years out of date. Any help here? | |
Re: I think that your test case here is ill advised. Here is why... The accumulate function is expecting a binary function as its fourth parameter. bind2nd returns a unary function (that is its purpose) by binding a value with the second parameter of a binary function. This allows use of … | |
Re: Simply declare the vector globally as yoiu would a normal global variable. The add the values you require to the vector using one of the methods availlable to vectors, e.g. push_back(). After that you shouldn't need to do anything. As a vector supports the subscript operator the rest of your … | |
Re: [QUOTE=photoyid;1154214]So I am working on a faux graphics program for class. The current part that I am working on is to determine just from top left and bottom right corners what the coordinates should be. I believe my logic is good but it seems to be setting it as tl(3,1) … | |
Re: [QUOTE=iamvish;1154491]Hi all, How to find free physical memory... I am using new operator to allocate memory.. I tried GlobalMemoryStatus (windows api) to analyse the current free memory. new is giving exception still GlobalMemoryStatus shows sufficient free memory.. I am using visual studio 2005 for development. and I want to avoid … | |
Re: instead of allocating arrays of char pointers try allocating a contiguous region of chars which is large enough to hold the whole board. Eg. board width = 10 board height = 5; char *board = new char[width * height]; now you can simply index into the char array using a … |
The End.