1,247 Posted Topics

Member Avatar for clarkkent021

See http://wiki.codeblocks.org/index.php?title=Creating_a_new_project In particular, http://wiki.codeblocks.org/index.php?title=Creating_a_new_project#Adding_a_blank_file http://wiki.codeblocks.org/index.php?title=Creating_a_new_project#Adding_a_pre-existing_file http://wiki.codeblocks.org/index.php?title=Creating_a_new_project#Removing_a_file

Member Avatar for vijayan121
0
274
Member Avatar for madhusudan.srinivasan

> Are you talking about hashmaps ? Or map in C++ ? Don't think so. Just about sorting both strings and the determining their set intersection. char amit[] = "AMITABH BACHCHAN" ; char rajn[] = "RAJNIKANTH" ; std::sort( std::begin(amit), std::end(amit)-1 ) ; std::sort( std::begin(rajn), std::end(rajn)-1 ) ; std::set_intersection( std::begin(amit), std::end(amit)-1, …

Member Avatar for ravenous
0
243
Member Avatar for theguitarist

> while const int may not even be given storage because the compiler may just treat it as if it were a macro by inserting its value wherever it is used. Yes, an object of type const int need not be stored anywhere. But then, the same is also true …

Member Avatar for mike_2000_17
0
6K
Member Avatar for venomxxl

CBase b; void func_set(CBase *pb) // pb may point to an object which has the dynamic type of some derived class of CBase { b = *pb; // the object *pb may be sliced here } See http://stackoverflow.com/questions/274626/what-is-the-slicing-problem-in-c > You probolly can get away with changing line 24 to > …

Member Avatar for venomxxl
0
121
Member Avatar for mferarri

> If you know where Bjarne has explained this, then say so, because I can't see it. I suppose it must be there somewhere in his book. Its definitely there on his support site for the book. http://www.stroustrup.com/Programming/std_lib_facilities.h

Member Avatar for mferarri
0
174
Member Avatar for VernonDozier

You should not be using a name like `_FOO` **anywhere** in your code. A name like `_fOO` can be used except in the global unnamed namespace. Just make sure that the character following the leading underscore is a lower case character.

Member Avatar for VernonDozier
0
788
Member Avatar for triumphost

Use `std::uninitialized_copy()` instead of `std::copy()` http://en.cppreference.com/w/cpp/memory/uninitialized_copy

Member Avatar for vijayan121
0
575
Member Avatar for mke48

The typical C++ approach is to simulate multimethods with multiple dispatch http://en.wikipedia.org/wiki/Multiple_dispatch or with the visitor pattern http://www.codeproject.com/Articles/7360/MultiMethods-in-C-Finding-a-complete-solution

Member Avatar for vijayan121
0
147
Member Avatar for Suzie999

> I'd like to use std::tr1::regex You have `int _tmain(int argc, _TCHAR* argv[])`; so presumably you are using the Microsoft compiler. If it is a recent version (2010 or later), use `std::regex` instead. > I was expecting all values between % and % The regular expression `%(.*?)%` consumes the terminating …

Member Avatar for Suzie999
0
2K
Member Avatar for Alexkid

> tellg() in my code as the function is not supported on the desired hardware. What hardware? A `std::istringstream` holds a `std::stringbuf` and it does not use anything other than memory allocated with the standard allocator. Have you tried printing out the result returned by `tellg()` on the string stream?

Member Avatar for vijayan121
0
756
Member Avatar for triumphost

All this is (conforming) C++: struct A { // http://www.stroustrup.com/C++11FAQ.html#default // http://www.stroustrup.com/C++11FAQ.html#constexpr constexpr A() = default ; // x == 0, y == 0 constexpr explicit A( int x ) : x(x) {} // A::x==x A::y==0 A( int x, int y ) { A::x = x ; this->y = y …

Member Avatar for mike_2000_17
0
492
Member Avatar for daino

> Are they compiled separately then linked? Yes. The linking may be done either statically or at load/run time from a .dll or .so

Member Avatar for daino
0
208
Member Avatar for gerard4143

> I'm interested in sorting a standard container called say 'first_container' via another container which has iterators pointing to the first container. An indirect sort is useful in many situations * a sequence is immutable, but we want a sorted view of the sequence * we want to access the …

Member Avatar for vijayan121
0
524
Member Avatar for Tinnin

> string::const_reverse_iterator rit = s.rbegin(); > This should be outside the loop(just before the loop) Yes. And you need not go all the way to `end()`; upto the middle of the string would suffice. Which would make the code equivalent to: bool is_palindrome( const std::string& str ) { return std::equal( …

Member Avatar for WaltP
0
156
Member Avatar for triumphost

The linker can't find the library files. You need to add one or more **-L<path to library files>** to the link command http://gcc.gnu.org/onlinedocs/gcc-4.7.1/gcc/Directory-Options.html#Directory-Options For example: **-LC:\MinGW\lib**

Member Avatar for vijayan121
0
2K
Member Avatar for Suzie999

> Main part of my project is to capture and parse all incoming and outgoing network traffic on the fly. Do you think that merits a performance concern? It certainly does. Bursts in network traffic are difficult to predict and difficult to simulate with any kind of accuracy. Nevertheless, performance …

Member Avatar for vijayan121
0
257
Member Avatar for Tinnin

> So my question is, why is it crashing? container_Student_info::iterator iter = students.begin() ; while(iter!=students.end()) { if(fgrade(*iter)) { // .... } else { it = students.begin(); students.insert(it, *iter) ; // the iterator 'iter' is no longer valid // because we have modified (added a new item into) the container // …

Member Avatar for Tinnin
0
117
Member Avatar for AutoPython

> I pretty much get what was posted (need to look up sprintf), but the code below gives me the error that "fname, MAX_FILE_NAME_LENGTH, and strlen" Why have you started messing around with all this stuff? Your origininal idea was far superior; just that you made a careless typo. Fix …

Member Avatar for AutoPython
0
4K
Member Avatar for Geli19

> Each constructor and destructor gets called each time the loop is executed... If this is what you want, arkoenig has already given you the solution. > The purpose is to create a brand new object each time the loop is executed for as long as the loop runs. Once …

Member Avatar for Geli19
0
5K
Member Avatar for 45lbplates

> I have a string and in it there is a character I want to remove. > What is the best way to remove it? Remove char at position **pos** in string **str** `str.erase( pos, 1 ) ;` or `str.erase( str.begin() + pos ) ;` or `str = str.substr(0,pos) + …

Member Avatar for vijayan121
0
5K
Member Avatar for Secone

Use `std::sort()` and `std::unique()` in <algorithm> #include <algorithm> #include <iostream> int main() { int a[] = { 0, 1, 0, 2, 3, 4, 3, 3, 5, 2 } ; enum { SIZE = sizeof(a) / sizeof(*a) } ; std::sort( a, a+SIZE ) ; const int size_unique = std::unique( a, a+SIZE …

Member Avatar for vijayan121
0
241
Member Avatar for daino

See the posts by arkoenig (towards the end) in this thread: http://www.daniweb.com/software-development/cpp/threads/360216/c-value-initialization

Member Avatar for vijayan121
0
301
Member Avatar for Tinnin

> The point of the exercise is to use list throughout rather than vector. Yes; the point of the exercise is to understand the difference between using a sequence container like `std::vector<>` that provides random access to its values and one like `std::list<>` that does not. double median( list<double> vec …

Member Avatar for Tinnin
0
173
Member Avatar for slasham

Use a library to do this. **libcurl** would be the default choice. http://curl.haxx.se/libcurl/ Sample source code: http://curl.haxx.se/libcurl/c/ftpget.html Tutorial: http://curl.haxx.se/libcurl/c/libcurl-tutorial.html

Member Avatar for np complete
0
866
Member Avatar for shmay
Member Avatar for trantran

See: http://www.daniweb.com/software-development/cpp/threads/392114/could-i-find-a-replacement-of-lokitypelist-from-boost

Member Avatar for trantran
0
763
Member Avatar for tiredoy

> So,what should I do to solve this problem? Write your own TRACE(). #include <cstdarg> #include <cstdio> #include <windows.h> #include <iostream> void TRACE( const char* format, ... ) { va_list args ; va_start( args, format ) ; enum { MAX_MESSAGE_SIZE = 4192 } ; char msg[ MAX_MESSAGE_SIZE ] ; std::vsnprintf( …

Member Avatar for vijayan121
0
212
Member Avatar for kneiel

if your idea was to have a code sample which will help you understand how virtual function calls are implemented by the microsoft compiler: [code=c++]#include <iostream> #if defined(_MSC_VER) && (_MSC_VER >= 1200) && defined(_M_IX86) struct A { // __stdcall, args passed on stack, 'this' is the first arg virtual void …

Member Avatar for AliceJohn123
0
696
Member Avatar for n.aggel

First, is this the "best" way to tackle the chat problem? no. it is unlikely that someone would want to set up a chat between two processes on the same machine, sharing stdin and stdout between them. write two separate programs; the server and the client. which can be run …

Member Avatar for Ambreshbiradar
0
1K
Member Avatar for shouvik.d

after exiting from main, the following actions are performed: a. call destructors of objects with static storage b. call atexit functions c. deinit the C runtime library during this, it was detected that some dynamically allocated memory block is invalid. this can occur due to a variety of reasons; but …

Member Avatar for atoutsweb
1
1K
Member Avatar for gerard4143

arkoenig wrote: > I would think that if you replace the type std::pair<std::string, unsigned long> in > lines 7 and 23 by std::pair<const std::string, unsigned long>, it ought to work. > At least I can't think immediately of any reason it shouldn't. I had always thought that this error (given …

Member Avatar for gerard4143
0
366
Member Avatar for Zssffssz

Use the standard smart pointers, perhaps? See: [url]http://www.devx.com/cplus/10MinuteSolution/39071/1954[/url] and: [url]http://www.devx.com/cplus/10MinuteSolution/28347/0/page/1[/url]

Member Avatar for MastAvalons
0
139
Member Avatar for daviddoria

> Of course I could add pure virtual functions in ImageBase and implement them in Image, > but then I will be using a modified version of the library, which is huge headaches for users. > Is there a way to do this without touching ImageBase? If the only issue …

Member Avatar for vijayan121
0
207
Member Avatar for the_kitoper

[CODE]int otherFunc(void) { float [COLOR="Red"]foo[/COLOR] = .5f; //assume widget has been created g_signal_connect(G_OBJECT(widget), "clicked", G_CALLBACK(kitty), (gpointer)[COLOR="Red"]&foo[/COLOR]); }[/CODE] Wouldn't this [B]foo[/B] be destroyed by the time the event handler [B]kitty[/B] is called? Also, do read up on comparing floating point values. [url]http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm[/url]

Member Avatar for vijayan121
0
198
Member Avatar for kchyn

http://software.intel.com/en-us/articles/intel-c-compiler-compatibility-with-microsoft-visual-c/#a_UIIDE

Member Avatar for vijayan121
0
237
Member Avatar for tomtetlaw

Native support for rtti in C++ is minimal; type-safe down and cross casts and a run-time type identifier (which apply to only polymorphic types). This is woefully inadequate to implement an architecture using the reflection pattern. [url]http://www.vico.org/pages/PatronsDisseny/Pattern%20Reflection/index.html[/url] Since the language is statically typed, programs are not run under an interpreter …

Member Avatar for mike_2000_17
0
547
Member Avatar for daviddoria

This would suffice:[CODE]template< typename T > void foo( const T& t ) ; template< typename T > void foo( const MyClass<T>& mc ) ;[/CODE] The partial ordering of templates involved (that is taken into account in the deduction process) would make the second template be preferred over the first for …

Member Avatar for daviddoria
0
171
Member Avatar for coxxie

If the sequence of characters in the input stream is valid (a sequence that could have been written out during output), consume all the valid characters and update the object to reflect the new values Else leave the object unchanged and set the stream to a failed state. With this …

Member Avatar for coxxie
0
457
Member Avatar for daviddoria

The IS specifies that a predicate should not assume that the dereferenced iterator yields a non-const object. Arguments should therefore be taken by reference-to-const or by value. The IS also specifies that algorithms that take function objects as arguments are permitted to copy those function objects. So in most cases, …

Member Avatar for vijayan121
0
4K
Member Avatar for Karlwakim

> Is it possible to write a c++ compiler in c++ ? The first C++ compiler was written in C++. [url]http://www2.research.att.com/~bs/bs_faq.html#bootstrapping[/url] Clang is written in pure C++; with heavy use of C++ facilities (like STL). [url]http://clang.llvm.org/[/url] Pretty well-written code too, IMHO.

Member Avatar for vijayan121
0
198
Member Avatar for BCBTP

> talk with an attorney who has some knowledge of intellectual property issues. +1

Member Avatar for vijayan121
0
197
Member Avatar for aKiLa.. :)

[B]sum+=(1/factorial(i)) ;[/B] Is integer division ok here? A more efficient way to sum up this series would be to use the recurrence relation between successive terms. [B]1/1! + 1/3! + 1/5! + ... = a<0> + a<1> + a<2> + ... a<0> = 1 ; a<1> = a<0> / (2*3), …

Member Avatar for adityatandon
0
104
Member Avatar for mrnobody

See: [url]http://publib.boulder.ibm.com/infocenter/aix/v6r1/index.jsp?topic=%2Fcom.ibm.aix.genprogc%2Fdoc%2Fgenprogc%2Fwriting_reentrant_thread_safe_code.htm[/url]

Member Avatar for rubberman
0
143
Member Avatar for kankaortiz

> how would i stop a user from entering a letter when they should be entering a number? There is no really portable way of doing that. What can be done is: let the user enter any set of characters, and if those do not form a valid number, ask …

Member Avatar for adityatandon
0
5K
Member Avatar for Srinivas0

"The most effective way to increase your knowledge is to try new problems in a controlled way. Pick [I]one[/I] aspect of C++ that you haven't understood before and write a program that, aside from using that one aspect, uses only things that you have already mastered. Then do what it …

Member Avatar for Srinivas0
0
189
Member Avatar for epicbeast9022

> s this legal? (For example, can I set a GUIComponent as the return of a function and instead return a subclass?) Yes. For example: [CODE]GUIComponent* getComponent() { return new TextLabel( /* ... */ )[/CODE] is fine, provided [B]TextLabel[/B] is a derived class of [B]GUIComponent[/B]. > Why is the compiler …

Member Avatar for vijayan121
0
175
Member Avatar for ThomsonGB

You have not opened the stream successfully - the [B]FILE*[/B] pointer was [B]NULL[/B] at the time you did an [B]fseek()[/B]. Verify that [B]fopen()[/B] returned a non-NULL pointer. (Perhaps you are using a relative path to file which is no longer correct for the project copied into a different directory).

Member Avatar for ThomsonGB
0
494
Member Avatar for n0de

In lines 90-93, change[code] Decorator ( Switch * sw ) : swit ( *sw ) { swit = sw; }[/code] To[code]Decorator ( Switch * sw ) : swit ( sw ) // initialize the [B][COLOR="Red"]pointer[/COLOR][/B] swit with sw {}[/code]

Member Avatar for n0de
0
153
Member Avatar for burcinerek

[b]N[/b] students to be given a different random ball each from a population of [B]M[/b] balls. [B]a[/B]. [B]M[/B] is not much larger than [b]N[/b] (for example 100 balls and 50 studenta): Generate a random permutation of the [B]M[/b] balls ([B]std::random_shuffle()[/B]) and assign the first ball in the permutation to the …

Member Avatar for vijayan121
0
289
Member Avatar for Despairy

> I cant seem to find anything useful on the web except adding outside libraries for this one With a conforming implementation, nothing more than the standard C++ library is needed. Something like this: [CODE]#include <thread> #include <atomic> #include <chrono> void save_file( const std::string& path, int minutes, std::atomic<bool>& keep_saving /* …

Member Avatar for Caligulaminus
0
942

The End.