6,741 Posted Topics
Re: [QUOTE]wrap your code in code tags. <snip> template <class T> class myClass { T myMember; } template <class T> T myClass<T>::getSomething(){return myMember;} [/QUOTE] Oh, the irony. | |
Re: [QUOTE]i was told objects can be created in C just like c++.[/QUOTE] Objects are really just lumping data and functions that operate on the data into one package. In C you can't have member functions, but you [i]can[/i] have pointers to functions: [code] #include <stdio.h> typedef struct foo foo; struct … | |
Re: [QUOTE]My understanding is that the Objects created are stored in the heap segment.[/QUOTE] Your understanding is incorrect. The location for an object depends on how it's created. [QUOTE]What if the objects are created for a class with static data members?[/QUOTE] The static data members are stored separately from instance data … | |
| |
Re: The problem is easily solved by throwing type safety out the door: [code] class Base { public: virtual void GetData(void *data) = 0; }; template <typename T> class Derived: public Base { int _data; public: Derived(int data): _data(data) {} virtual void GetData(void *data) { *(int*)data = _data; } }; #include … | |
Re: Nothing magical going on here, but in an uncharacteristic move, I actually added comments. Yes, I'm bored: [code=cplusplus] #include <string> #include <vector> //! Maintains a collection of substrings that are //! delimited by a string of one or more characters class Splitter { //! Contains the split tokens std::vector<std::string> _tokens; … | |
Re: exp[101] is out of bounds. | |
![]() | |
Re: Can you post a short code example of what you're doing? | |
Re: We're not programmers for hire. This forum is for people who want to do the work themselves and need a bit of help. | |
Re: [QUOTE]I don't know how to prevent my other output to be cleared when I use clear screen.[/QUOTE] That's because clrscr clears the whole screen. :icon_rolleyes: The vanilla console doesn't lend itself well to non-linear drawing. You'd probably be better off either going full GUI, or take advantage of something like … ![]() | |
Re: [QUOTE]how do you typedef a function?[/QUOTE] You don't. The code you posted is a typedef for a [I]pointer to[/I] a function. | |
Re: I'm a little biased, but I believe [URL="http://www.eternallyconfuzzled.com/tuts/datastructures/jsw_tut_linklist.aspx"]this[/URL] is a well written explanation. The code is in C, but the changes necessary to compile the examples as C++ are minor and pretty much just constitute an explicit cast. | |
Re: Sculpting, flower arrangement, ballet, and firework pyrotechnics. I would like to know the difference between these listed. | |
Re: Let's break it down a bit. A function has four parts: [list=1] [*]An identifier [*]A return type [*]A parameter list [*]A body [/list] The first three are combined to create the function's signature, and it looks like this: [I]<return type>[/I] [B]<identifier>[/B]([I]<parameter list>[/I]) The parameter list is enclosed in parentheses simply … | |
Re: >It looks as if you are automatically assuming that Z is an integer That's a reasonable assumption seeing as how Z was declared as int. >When it's not an integer, but it's treated as one, you could end up in some sorta loop further down in your program. The problem … | |
Re: [QUOTE]it's not about anything I may or may not have posted, but about not wanting to be here at all.[/QUOTE] Then leave and don't come back. I fail to see what's so difficult about this. If you're worried about identifying information, you wouldn't have it anywhere on your account in … | |
Re: >So obviously I am missing a fundamental part of the logical not operator. Let's break it down, starting with the if statement: [code=cplusplus] if ( ... ) { ... } [/code] If the condition is true, execute the block. Simple, right? Now let's add a boolean test: [code=cplusplus] if ( … | |
Re: [QUOTE]any idea what sort of cryptography that might be?[/QUOTE] The zero padding suggests a block cipher of some sort. If you're trying to generate passwords that are accepted by the game or decrypt passwords from the game, you're looking at some serious cryptanalysis. Not only do you need to figure … | |
Re: The easiest solution is to first try opening one of the following streams: [code] ofstream pout("PRN"); ofstream pout("LPT1"); ofstream pout("PRN:"); ofstream pout("LPT1:"); [/code] If none of those work, and your compiler doesn't support an extension for talking to a printer, google over to MSDN and see what you can find. … | |
Re: >Thanx for the great response :( Bite me. Now I'm not going to help you. But all is not lost because I found a C++ implementation of this on google that would give you a nice start. It took me about 7 seconds. | |
Re: [QUOTE]I see at SNIP that most computer jobs require a Bachelors degree.[/QUOTE] That's boilerplate these days, but a stronger degree will certainly help you get an interview when your resume is in a stack. [QUOTE]I just wanted to get an "idea" of where I'd stand with both from somebody already … | |
Re: And what have you done to help yourself first? Your question sounds a lot like "I don't want to think, do it for me." | |
Re: Interpreted code isn't necessarily executed line by line. In many cases it's compiled to an easier to run intermediate form (Java bytecode, for example). While an interpreter might be one program that reads and runs source code all at the same time, often you'll really have two programs under the … | |
Re: [QUOTE=vienne][B]I'm having a problem with my sorting algorithm. before I made quick sort which used insertion sort, but I don't want to use this insertion sort. I want to use recursive algorithm. Also, I want to get new idea, so If you know any quick sort algorithm, reply for me.Please~ … | |
Re: [QUOTE]I don't understand what is wrong with writing code like: Wood a, b, c; (a * b) = c;[/QUOTE] There's nothing [i]wrong[/i] per se. It's generally frowned upon because when overloading operators, the general rule of thumb is "do as the ints do", or match the semantics of built-in types. … | |
Re: If I were you, I'd start by defining exactly what you mean by "dictionary". | |
Re: Your prototype of fun says that sum and avg are floats. Your definition says that sum and avg are pointers to float. Make up your mind. | |
Re: I've seen the term used in two contexts: [list=1] [*]An algorithm for an undecidable problem. In other words, there's no proof that the algorithm will reach a conclusion in finite time. [*]In reference to hypercomputation theory. [/list] | |
Re: [QUOTE]I do not have that error with feof[/QUOTE] That doesn't make it any less of a bug. | |
Re: Your teacher made up that term. You should ask him what it means. | |
Re: [QUOTE]don't want someone to do my work for me, but need direct and timely answers to questions, immediately[/QUOTE] You'll get direct and timely answers for free simply by posting your questions here. If you don't believe me, I suspect we have differing opinions on what constitutes doing your work for … | |
Re: tmp first needs to point something: [code] user init; user *tmp = &init; [/code] | |
Re: Your prototype and definition of do_stuff don't match. int and a reference to an int are two different types. | |
Re: [QUOTE]Does anyone know what this is?[/QUOTE] It's just a macro that's either blank or represents the compiler's keyword for a far pointer (Ã la Intel's 16-bit segmented memory model). [QUOTE]could someone explain the difference between these two lines (after the typedef executes)[/QUOTE] One is a pointer, the other is an … | |
Re: Your declaration and definition don't match. The friend declared in your class is not a template while the defined operator<< is. | |
Re: [QUOTE]Couldn't they have just used size_t instead?[/QUOTE] Sure, but there were two reasons to define size_type: [list=1] [*]Support custom allocators and different memory management strategies without forcing code changes. [*]Historically, size_type was added to the STL implementation to deal with a problem on the Intel architecture (no, I don't know … | |
Re: There's too much complexity involved in overloading on return type. It's simply not valuable enough to justify the cost of the feature. | |
Re: I don't see you terminating your string with '\0'. That's required by atoi or you'll walk right off the end. | |
Re: All of the is* functions accept an int type, but the range must either fit into an unsigned char or equal the EOF macro. In this case, you can use cin's status to determine validity: [code] #include <iostream> #include <ios> #include <limits> int main() { int amount; while (!(std::cin>> amount)) … | |
Re: [QUOTE]what will be its output:??[/QUOTE] No output. It's not C, and won't compile as C++ either due to syntax errors. But you'd know that if you tried compiling it. :icon_rolleyes: | |
Re: [QUOTE]If you were a programmer, you'd know by that logic you could also say, "I know 'Hello' in Chinese, therefore I'm fluent in it". ;P[/QUOTE] Faulty logic. He said "I'm a programmer", not anything about fluency. The argument could be made that one knows Chinese after learning one word, though … | |
Re: Please stop posting poorly formated non-standard code for no reason at all. If you insist on spamming the forum with pointless threads, I'll delete them without hesitation. | |
Re: If your algorithm is written to handle binary files (as opposed to text), then it really comes down to whether to file compresses well or not. Multimedia tends to be compressed already, so LZW might not yield good results. | |
![]() | Re: [QUOTE]Your code is almost unreadable.[/QUOTE] Are you on crack? The code is both consistent and intelligently formatted. The only truly odd thing I can see is a tab on both sides of the assignment operator, but that's hardly enough to cause one to trip up when reading. |
Re: [QUOTE]I ws just wondering what kind of knowledge one would need to learn to program.[/QUOTE] You don't need any knowledge, but computer power user skills will go a long long way. If, for example, all you know how to do is send email and surf the web, you'll have a … | |
Re: C isn't a protected environment. You can do these things, but you can't rely on the result being predictable or reproducible. | |
Re: [QUOTE=bbman;1445573]Thanks for your reply, i got it working.. just one more problem, i need to get the number quick.. but since the seed depends on time, if i call the function again within the same second, it gives me the same random number.. anyway to EASILY fix that? like by … | |
Re: Please learn to type like an intelligent human. Those stupid abbreviations don't encourage clueful people to help you, and might even turn away non-native English speakers who could have trouble even deciphering your post. |
The End.