353 Posted Topics

Member Avatar for twc2102

The boost::thread class forward declares a struct called dummy. Long story short, you can work around it by adding a definition in one of the.cpp files for your project. [code] namespace boost { struct thread::dummy {}; } [/code] For AkashL, just create a console CLR project and throw in a …

Member Avatar for twc2102
0
2K
Member Avatar for dansnyderECE

[url]http://www.cplusplus.com/reference/string/string/replace/[/url] :)

Member Avatar for dansnyderECE
0
152
Member Avatar for nu2cpp

Fun. :) How about something brute force to get you going? [code] for (int i = 0; i < rows; ++i) { int k = i * 2, m = 0; for (int j = 0; j < cols; j += 2) { int offset = k + (rows * …

Member Avatar for Radical Edward
0
9K
Member Avatar for 316heath

It does not look comprehensive at all. With so many completely different topics and only 2 years, Edward cannot imagine you would become especially competent in any of them without a lot of extra self study. But if it is an accredited school, the degree you get will help in …

Member Avatar for jmg2hp
0
119
Member Avatar for leone86

> I'm not saying your style's wrong; but it's better to slim down on your lines of code. The two styles do different things. The first style only makes the specified names available. The second style makes all names in the namespace available. It is easier to get name collisions …

Member Avatar for Radical Edward
0
114
Member Avatar for dansnyderECE

> Are there any roads you can keep me from going down in this process? Unless failure means big money loss, Edward prefers to throw juniors to the wolves. The school of hard knocks is the most effective one, after all. :D Try designing and writing the program yourself once, …

Member Avatar for Radical Edward
0
100
Member Avatar for M.manning

> Yet when I got rid of those new initializations it went back to running perfectly well. Given that description, Edward would guess that previously run code has corrupted the stack pointer. Bus errors usually happen when code tries to read or write to misaligned addresses. If the stack pointer …

Member Avatar for Radical Edward
0
66
Member Avatar for sadhawan

Your problem looks like the classic trick question: "What is the time complexity of printing a binary search tree?". It is a trick question because "everyone knows" that binary search trees are have logarithmic complexity, but to print all of the nodes in the tree, the algorithm still has to …

Member Avatar for sadhawan
0
98
Member Avatar for edk.theg8

As long as the file format supports that kind of formatting, sure. Edward can copy code from Visual Studio to MS Word and formatting/coloring is preserved. Whether it's a good idea or not is something you can to figure out on your own. :)

Member Avatar for Radical Edward
0
44
Member Avatar for gajapathi10

> how i can develop my own programming language that will fullfills all the requirements of the present industry Scala already exists, and it's a beast. :D It sounds like you want to create a *real* language as opposed to a toy for learning language design and implementation. Start by …

Member Avatar for AuburnMathTutor
0
116
Member Avatar for Finconizer

Edward can't help but think of malware when program requirements include words like "secretly".

Member Avatar for nbaztec
0
148
Member Avatar for Hawkpath

Edward would like to master the basics... Nothing is more marketable than a developer with super sturdy foundations. > So now I'm thinking "What now"? Now you start writing software. There are system APIs and GUI APIs, and tools like Boost that will keep you busy learning for a long …

Member Avatar for NathanOliver
0
139
Member Avatar for fandango

> This is surely a massive performance hit, especially if classes contain allocation and de-allocation statements? It *can* be too much overhead, but in those cases you should be storing a vector of light weight smart pointers. [code] int main() { vector<shared_ptr<Foo> > container; for (int i = 0; i …

Member Avatar for Radical Edward
0
223
Member Avatar for ShortYute

These samples are using Boost and totally from memory. Please excuse any lapses in Ed's ability to recall details of a complex library. :D The concepts should be accurate though, and easy to correct from the Boost documentation. > mkdir () // make a new folder [code] #include <boost/filesystem/path.hpp> #include …

Member Avatar for ShortYute
0
2K
Member Avatar for Ferny84

[LIST=1] [*]The file is closed in the loop. That does not work well if you want the loop to continue reading the file. ;) [*]The file reading loop does not do anything else. Only the last book in the file will be printed. [*]createBook returns a pointer to the new …

Member Avatar for Radical Edward
0
98
Member Avatar for gidireich

> It there any way to telll the compiler that from this to that point, everything I implement belongs to a certain class? There is no way the compiler knows that you are implementing a member outside of a class definition unless the name is qualified. The only way to …

Member Avatar for Radical Edward
0
147
Member Avatar for literal

> 1. What are the most recommended books on c++ algorithms? Knuth's Art of Programming books are the only ones consistently recommended, but they are not in C++. > 2. Algorithms in C++ by Robert Sedgewick - any experiences? Great book, worst code ever. Edward still recommends it because the …

Member Avatar for literal
0
109
Member Avatar for memstick

> What is the point (eheh) of a pointer to a pointer? The two most common uses are faking a 2D array with heap memory, and faking pass by reference for a pointer. The code you posted looks like the latter. The output of the function is a pointer, but …

Member Avatar for memstick
0
118
Member Avatar for PatMcC

> Please don't say perl.... Edward can only assume you are prohibiting Perl because it is the most obvious and correct answer to your question. ;) Modern "scripting" languages with native regular expression support are going to be your best bet. Perhaps Python or Ruby?

Member Avatar for PatMcC
0
83
Member Avatar for ronnieaka

lobjc is the Objective-C library. You do not need it in C++, so remove it from the list of included libraries and that error should go away. Edward has not used Dev C++ in ages though. You will need to figure out where to make that change. Probably in the …

Member Avatar for u8sand
0
213
Member Avatar for vsawant

In anticipation of the thread being split, Ed has a comment. > I suggest using a bitwise AND (much quicker as it doesn't involve a division) This is a common misconception. Every time Edward tries to confirm such claims, the result is that the two are competitive at all optimization …

Member Avatar for ZootAllures
-1
152
Member Avatar for shankarz

> because a char array is the same as a char * This can be a misleading statement. Arrays are not pointers, but an array name *is* converted to a pointer most of the time in practice. > every one know that scanf statement should use "&" ambers ion > …

Member Avatar for mehrab
0
263
Member Avatar for fernandofranca

getline()'s first parameter is an istream reference. It looks like you want an intermediate string stream. [code] #include <fstream> #include <iostream> #include <string> #include <sstream> #include <cstdlib> // For exit() int main() { std::ifstream arquivo("entrada.txt"); if (!arquivo) { std::cout << "File not found\n\n"; std::system("PAUSE"); std::exit(EXIT_FAILURE); } else { std::cout << …

Member Avatar for fernandofranca
0
983
Member Avatar for flaviusilaghi

What do you mean by "bad_ptr"? Edward doesn't have any problems with that syntax. [code] #include <iostream> #include <iomanip> int main() { const int n = 16; unsigned int **intext; intext = new unsigned int*[n]; for (int i = 0; i < n; i++) intext[i] = new unsigned int[n]; for …

Member Avatar for flaviusilaghi
0
160
Member Avatar for abhi74k

Assuming the question is about construction of an object in a class hierarchy, Edward has trouble answering questions that are answered easily by Ed's intuition. Why does it not make sense for the base parts of an object to be constructed before the derived parts?

Member Avatar for abhi74k
0
149
Member Avatar for GAME

It's easy to write slow applications with WinForms, but there are [URL="http://msdn.microsoft.com/en-us/magazine/cc163630.aspx"]general applicable tips[/URL] for keeping things snappy. Anything more specific depends on how your forms are set up and what they do.

Member Avatar for GAME
0
103
Member Avatar for abhi74k
Member Avatar for abhi74k
0
53
Member Avatar for virendra_sharma

> i want to know , how to optimize bubble sort Switch to a faster algorithm. :D Bubble sort is one of the least efficient sorting algorithms, to the point that trying to optimize it is wasted effort when even switching to another quadratic performance algorithm like insertion sort would …

Member Avatar for bbman
0
632
Member Avatar for Radical Edward

...does not work in Firefox 3.6.3. The page is scrolled to the top and the code box remains in highlighted mode.

Member Avatar for Dani
1
66
Member Avatar for AbhikGhosh

How do you know it's obsolete if you don't know whether something newer exists? Obsolete means there is a newer method, not that the article describing the current method is old. ;) If you just want a recently updated article, the [URL="http://java.sun.com/docs/books/tutorial/2d/printing/index.html"]Java Tutorial[/URL] is a good start.

Member Avatar for AbhikGhosh
0
321
Member Avatar for dansnyderECE

> is the absence of a definition of the vector element the reason why you say this is not valid? Probably. If the vector is empty then v[0] is an out of bounds access.

Member Avatar for dansnyderECE
0
184
Member Avatar for dohpaz42

Template parameters are not polymorphic that way. One way to do what you want is to put identifying information in the base class and require that information in the container class. [code] class Base { public: enum { BASE_TYPE }; // Identifying information virtual ~Base() {} }; class Derived : …

Member Avatar for dohpaz42
0
207
Member Avatar for sdhawan

Single quotes in a string should be fine, but you might need to escape the embedded double quotes. [code] string s = "L'Oreal assures us \"You're worth it\"."; [/code]

Member Avatar for sdhawan
0
331
Member Avatar for shadowuy

> bobby = new int(numero); This dynamically allocates *one* int with the value of numero. Square brackets are used to allocate arrays. [code] bobby = new int[numero]; [/code]

Member Avatar for thelamb
0
175
Member Avatar for panda_pow

If j needs to persist between method calls, it should probably be a private data member instead of a local variable.

Member Avatar for panda_pow
0
150
Member Avatar for nshh

> 1) How can I free the memory from main(). But the memory was allocated in function a(). If you do not have a pointer to the memory, it is lost. > 2) How can I return the local pointer variable? Your code is fine. Returning a pointer to dynamic …

Member Avatar for Radical Edward
0
133
Member Avatar for moni94

C# and C++ can both do these things, it is just a matter of how much work you are willing to put into writing the classes.

Member Avatar for Rashakil Fol
0
132
Member Avatar for uttamsarnaik

Ctrl+Alt+Del is a secure attention sequence that cannot be intercepted by running applications. The whole point of a secure sequence is that one can be sure the OS is processing it rather than a malicious program. Edward cannot think of any benign reason why someone might want to disable it.

Member Avatar for Ketsuekiame
0
141
Member Avatar for dansnyderECE

> I can't determine how to specify the maximum number of characters to read. scanf() does not offer a user-defined field width like printf(). The way to make it dynamic is with sprintf. [code] char fmt[15]; char *data = malloc(n); sprintf(fmt, "%%dc", n); scanf(fmt, data); [/code] Why not just use …

Member Avatar for dansnyderECE
0
96
Member Avatar for riu

> Thats called hashing. Hashing is not guaranteed to produce unique codes except in special circumstances. The answer to this question really depends on what the code is used for. The needs of the program determine how the code is generated. For example, if the code is unique for each …

Member Avatar for oz_engineer
0
230
Member Avatar for johndoe444

memset() will fill an array with a value. If you need special logic to copy a value, then some kind of manual loop is pretty much the only way.

Member Avatar for johndoe444
0
171
Member Avatar for miturian

Libraries have two parts. You have the header and included it in your code, but did you link with the built object file paired with the header? The object files for libraries on Linux are usually .so for static libraries. Your build command should look something like this for gsl. …

Member Avatar for miturian
0
2K
Member Avatar for kenji

> b) will my variable z go out of scope before it goes through the whole vector. No sir. The scope of z is the same as the scope of the vector, so as long as you can access the vector object, you can access z. :) > a) how …

Member Avatar for arkoenig
0
154
Member Avatar for tennis

> This should cause a coredump or crash because it uses an uninitialized pointer Yes, but normally a static method is called using the class name when it cannot be called on an object. [code] A *a = A::create(); [/code]

Member Avatar for Radical Edward
0
110
Member Avatar for iXmerof

> way1 = temp; Edward will guess that way1 is declared as [code] CPoint way1[10]; [/code] Arrays in C++ are almost-but-not-quite first class types because they do not allow assignment. To copy items from one array to another, or from a dynamic array to a static array, each element must …

Member Avatar for iXmerof
0
99
Member Avatar for Bluefox815

Executable statements have to be inside of a function. These are the executable statements in your header file. [code] word_list->input = "a"; word_list[0].output = "b"; (word_list+1)->input = "c"; (word_list[1]).output = "d"; [/code]

Member Avatar for Bluefox815
0
305
Member Avatar for mcodesmart

Local variables are destroyed when the parent function returns. In combine(), the r array is a local variable. Even if you return a pointer to it, the array will still cease to exist when combine returns. Two ways around that problem are passing a buffer and returning a pointer to …

Member Avatar for Bluefox815
0
197
Member Avatar for FierceLeming

The golden rule is thusly: If you call malloc, calloc, or realloc, you must call free on the pointer returned or risk a memory leak. > 1) If I declare a variable in a block of code as a character array, I'm making a pointer to it. You are making …

Member Avatar for Radical Edward
0
144
Member Avatar for genux

> how does the compiler, running program ? know how much memory to delete There is a lot of plumbing behind new that manages info like how many bytes are in an assigned block. delete uses that info to free the block. > why cannot the developer access that size …

Member Avatar for genux
0
94
Member Avatar for spartan118

> 1. Is there a way, in C++ to do a do - if loop? You might need to explain how the logic of a do - if loop works. Edward can think of more than one way, but this one is intuitive. [code] if (condition) { do { // …

Member Avatar for Radical Edward
0
114

The End.