6,741 Posted Topics
Re: [QUOTE]wchar_t is a macro windows uses to replace it with either "CHAR" or "WCHAR" when UNICODE is defined.[/QUOTE] I believe you mean TCHAR. wchar_t is a keyword in C++. [QUOTE]MSDN says that UNICODE is defined by default.[/QUOTE] When you create a new project from a template in Visual Studio. This … | |
Re: dr isn't a member function...there's a lot more wrong here than void. | |
Re: [QUOTE]If the file is there, the new elements need to override everything in the file, pretty much clear it out and write to the file. If the file is not there, it just writes the elements to the file.[/QUOTE] The default behavior when opening for writing is to truncate the … | |
Re: [QUOTE]Because I honestly feel like I'll never understand them(it's been years by the way).[/QUOTE] If you want to feel like you understand things, quit programming immediately. I like to say that any decent programmer will be in a constant state of confusion. [QUOTE]my EXACT question is can it be done?[/QUOTE] … | |
Re: [iCODE]delete ptr[/iCODE] doesn't remove the node from the list, it simply releases the memory. The list still refers to a dangling pointer. deleteNode is also rather inefficient because it traverses the list twice: first to find a match and again to do the deletion. You can roll these together: [code] … | |
Re: [QUOTE]If there are a bunch of unique items, which one (vector or set) wold be more efficient to search for a particular item by value and why?[/QUOTE] The performance characteristics of the set class imply a balanced binary search tree (or similar) structure. vector is essentially a dynamic array. You'd … | |
Re: [QUOTE]I tried to include both headers, did both required tasks but only one of the windows opens.[/QUOTE] There can only be one entry point into the program. For a console project that entry point is the traditional main(). For a Windows project, the entry point is WinMain. If you want … | |
Re: No, it's not bad. Only C++ purists will rag on you about it, but they're in a world of their own anyway. | |
Re: In other words, you're completely incompetent. Massive ideas but an inability to follow through with them makes you utterly valueless. Then again, you're very obviously a troll who has no interest in following through with massive ideas. Rather, you're simply trying to get jollies out of wasting people's time. | |
Re: [QUOTE=spoonlicker;1477807]No, I mean machine language and not Assembly programming.[/QUOTE] Totally saw that one coming. :icon_rolleyes: If you want to work directly with machine language, get a hex editor. The only way to work with machine language is to directly modify the bytes of a file much the same way an … | |
Re: No, std::vector does not perform a deep copy of pointer items. You must do it manually or use a smart pointer. | |
Re: [QUOTE]it still doesn't help me with my program in OpenGL.[/QUOTE] That's because [i]if[/i] you truly don't understand as you say, you have no business delving into Win32 and OpenGL before properly learning the basics of C or C++. [QUOTE]Handles like Windows HWND? I know how to use those pretty fairly, … | |
Re: Sorry dude, we're not going to do your homework. I hope you don't think we're dumb enough to fall for the "this is a challenge for everyone!" trick. | |
Re: [QUOTE]it didn't work[/QUOTE] Not helpful. How didn't it work? | |
Re: [B]>int array[size];[/B] This won't work in standard C++. Array sizes must be compile time constants, and your size variable is not. If it compiles, you're relying on a compiler extension which isn't good when learning the language. [B]>bubblesort(array[],size);[/B] The brackets aren't necessary when referring to the array object itself: [code] … | |
Re: [QUOTE]Honestly, can it all be done with machine language and native graphics card and sound card instructions and nothing more?[/QUOTE] Yes. But writing machine code directly and interfacing directly with hardware is both difficult and tedious. I assume since you're excessively insane about not using the efforts of others that … | |
Re: [QUOTE=user422;1477367]Here's an example based on your request: [CODE]#include <iostream> int main(){ double numInput; while(true){ std::cout << "Enter a Number (Max 10 digits)(99 to Exit): "; std::cin >> numInput; if( numInput - static_cast<int>(numInput) != 0.0 ) std::cout << "Invalid Try Again" << std::endl; else break; } if( numInput == 99.0 ) … | |
Re: >could you elaborate I'd be happy to elaborate. jwenting was saying to RTFM. If that doesn't work, tell us what compiler you're using and we'll tell you how to get an executable file out of it. | |
Re: [QUOTE]I automatically know what it'll do because "I" came up with it.[/QUOTE] Until you leave the code and come back in a year and it looks like it was written by someone else. Then you're SOL. | |
| |
Re: You can implement operator== for your class, or alternatively use find_if, which takes a predicate: [code] #include <algorithm> #include <functional> struct id_match: public binary_function<A, int, bool> { bool operator()(const A& obj, int id) const { return obj.ID == id; } }; //... match = find_if(l.begin(), l.end(), bind2nd(id_match(), 999)); [/code] A … | |
Re: Did you search google? There's a lot of information on agile already out there. | |
Re: [QUOTE]2) Learn how to indent C++ code.[/QUOTE] The code is indented properly. Perhaps you could get to the root of the problem instead and mention that mixing tabs and spaces can affect indentation when pasted outside of an IDE. | |
Re: [QUOTE=spoonlicker;1475292]I know this is off-topic, but why did you assume I was male?[/QUOTE] Unless you're talking about the snipped profanity, I don't see any such assumption in this thread. But it's generally a good assumption on this kind of forum. It's also easier to make an assumption and go with … | |
Re: How to search the forum before asking a question that's been answered countless times before? | |
Re: There's no need to copy members individually. You can simply copy the structure objects: [code] timesheet[j] = timesheet[j + 1]; [/code] | |
Re: How do you attach a pointer to an int? [code] int i; int *p = &i; [/code] Right? Well, pointers are very regular, and you'll find that the same syntax works almost across the board: [code] vector<int> v; vector<int> *p = &v; [/code] | |
Re: struct and class are essentially the same thing, just with different default access. structs are public by default and classes are private. typedef is a completely different beast, and I'm curious what kind of misunderstanding prompted you to lump them together. Perhaps this little trick from C to avoid typing … | |
Re: Since you didn't mention what compiler or OS you're using, the only suggestion I can make is the std::system function from <cstdlib>. Look that up in your standard library reference. | |
| |
Re: [QUOTE]I understand the validation would be a display of the entered date so the user can verify it is correct.[/QUOTE] That's probably not a good assumption. More likely is that you're required to programmatically evaluate the date and determine if it's valid. [QUOTE]1. Does this declare a data type or … | |
Re: [QUOTE]My computer science teacher stinks.[/QUOTE] [QUOTE]the book sucks and doesn't explain anything[/QUOTE] [QUOTE][...] even though this class stinks?[/QUOTE] Did you consider that the problem might be on your end? Far be it from me to suggest that all teachers are great and it's the students who fail at learning, but … | |
Re: [code] #include <iostream> template <typename T> void display(T value) { std::cout<< value <<'\n'; } int main() { int a = 123; double b = 123.456; display(a); display(b); } [/code] This causes the template to be instantiated twice, once with each unique signature: [code] #include <iostream> void display(int value) { std::cout<< … | |
Re: [QUOTE]what is complexity in c++[/QUOTE] Time complexity of an algorithm is how long it takes the algorithm to complete, relative to the size of its input. If you have a question that relates to C++ (since time complexity is pervasive across the whole of computer science), be more specific. | |
Re: [QUOTE]I don't know where it from getting arguments.[/QUOTE] The C++ runtime environment, along with doing things like opening standard streams and such, will prepare command line arguments and call main. | |
Re: [QUOTE]Can anyone help me think of a better solution?[/QUOTE] You can follow a similar train of thought as nrand. Calculate the number of RAND_MAX sized buckets in your extended range, then for a randomly selected number of those buckets, add RAND_MAX to r. | |
Re: You want a random shuffle. Simply filling the array with random values will very likely produce duplicates. Shuffling multi-dimensional arrays is harder, so the usual advice is to shuffle a one-dimensional array and then copy the results into your final two-dimensional array: [code] #include <stdio.h> #include <stdlib.h> void swap(int *a, … | |
Re: [QUOTE]Why I get access violation in this code ?[/QUOTE] Because pointers are not magic. When you declare a pointer, it doesn't automatically point to an infinite amount of memory. In fact, it doesn't point to usable memory at all. You have to explicitly point it to memory that you own, … | |
Re: [QUOTE=elsiekins;1470225]Hello Using : [CODE] cout << "enter 5 letter"; getline(cin, letter); [/CODE] executes fine but when running PC- Lint: getline(cin, expectedLabel): error 534: (Warning -- Ignoring return value of function 'std::getline(std::basic_istream<char,std::char_traits<char>> &, std::basic_string<char,std::char_traits<char>,std::allocator<char>> &)' error 830: (Info -- Location cited in prior message) I was wondering if anyone could tell … | |
Re: No, we don't do homework. But if you do the work yourself, we'll be happy to help you along. | |
Re: You really have no choice but to shift elements and overwrite the elements to be deleted: Original: {[COLOR="Green"]1,2,3,4,5,6,7[/COLOR]} Delete 4: {[COLOR="green"]1,2,3,[/COLOR][COLOR="Red"]5,6,7[/COLOR],7} Delete 5: {[COLOR="Green"]1,2,3,[/COLOR][COLOR="Red"]6,7[/COLOR],7,7} The size of the array won't change though (I gave an example of how that might look with the black elements), so you need to maintain … | |
Re: Backslash in a string literal begins an escape character. If you want a literal backslash, double them up: [code] infile.open("C:\\201\\PigLatin.txt"); [/code] Alternatively, you can use forward slashes. That works too: [code] infile.open("C:/201/PigLatin.txt"); [/code] [QUOTE]missing function header (old-style formal list?)[/QUOTE] This means the compiler thinks you're starting a function body. Usually … | |
Re: [QUOTE]Why does fopen_s have the paramater FILE **_File rather then the FILE *_File that fopen has?[/QUOTE] Standard fopen returns the FILE pointer, but fopen_s instead returns an error code. Thus, an output parameter in the form of a pointer to a pointer to FILE is used to "return" a handle … | |
Re: What kind of hacker? You have the traditional hackers who treat learning new things almost as a religion, and the more recent hackers who break into and defend systems. Are you talking about the subculture as a whole, or do you want individual anecdotes? I can personally vouch that there's … | |
Re: [QUOTE]My question is that everyone says C/C++ is more powerful than many other languges e.g Visual basic but why is it more powerful.[/QUOTE] Not everyone. Making such a claim is misleading because the definition of "powerful" hasn't been nailed down. Yes, C and C++ are both powerful languages, but other … | |
Re: I don't really see how this would help. Either you know the material or you don't. A thread of interview questions won't change that. You might get lucky and be asked a question that shows up in this thread, but that's kind of like sleeping with the textbook under your … | |
Re: [QUOTE]However, const_reference at() const never gets called. Can anyone see why this is?[/QUOTE] None of your objects are const. The compiler isn't exactly going to say "oh, that call is on the right hand side of an assignment, the programmer must want me to use the const version of this … | |
Re: [QUOTE]1. Do we have static classes in C++?[/QUOTE] Since this question was given to you by a Java programmer, you have to consider what a static class is in Java and then see if C++ supports the same behavior. In Java, a static modifier is only allowed on nested classes, … | |
Re: Consistent formatting would help to highlight these problems. |
The End.