3,183 Posted Topics

Member Avatar for VernonDozier

> When a's destructor is not virtual and either b's or c's IS virtual, the program crashes. I'm not sure why this one happens. I don't know off the top of my head, but I'd guesstimate that this invokes undefined behavior somehow and crashing was the result. > When a's …

Member Avatar for VernonDozier
0
220
Member Avatar for binningen

> test.txt is stored in the same directory as my XCode project. But is that the current working directory for XCode (assuming you're running directly from the IDE)? Use perror() to get a more useful error message: FILE* f = fopen("test.txt", "r"); if (f == NULL) std::perror("Error opening file"); I …

Member Avatar for binningen
0
1K
Member Avatar for triumphost

> typedef long static_cast<*stringFromString>((int, char*)) __cdecl; This is completely nonsensical. Casting is a form of coercion of *objects* to another type. The bytes of the *object* are interpreted as the new type. A typedef is not an object. > SmartSetup((char*)World.c_str(), (char*)",f5", 765, 503,(char*)""); > //TO: > SmartSetup(static_cast<char*>(World.c_str()), static_cast<char*>(",f5"), 765, 503, …

Member Avatar for mike_2000_17
0
668
Member Avatar for happygeek
Member Avatar for happygeek
0
230
Member Avatar for triumphost

Parameter names aren't required in a function declaration, though it's generally viewed as poor style to take advantage of that (mis)feature. You can also omit the parameter name if you don't use the parameter, even if it's a definition, which can be useful every now and again to match interfaces: …

Member Avatar for deceptikon
0
130
Member Avatar for Dani

> I would recommend that moderators get more involved with thier members, not only in answering questions, but also in the voting and commenting process. I'd be shocked if most or all of the moderators didn't already participate heavily in this way. One of the reasons mods attracted attention for …

Member Avatar for TrustyTony
0
956
Member Avatar for merse

I suppose the optimal type would be the one std::vector exposes for you: std::vector<T> v; ... // Use the provided size_type for (std::vector<T>::size_type i = 0; i < v.size(); ++i) { ... } That's rather verbose, so you can hide it behind a typedef prior to C++11, or use auto …

Member Avatar for L7Sqr
0
126
Member Avatar for iAndrewMeyer

Your initial allocation loop iterates far too many times. The overall process looks fine though. I'd write it like this: int rows = numCouples * 2; int cols = numCouples; int** ratings = malloc(rows * sizeof *ratings); // Check if malloc() failed... for (i = 0; i < rows; ++i) …

Member Avatar for Trentacle
0
141
Member Avatar for firdousahmad

"Help me please" is not a good question. Please be specific about what you want help with. I'd also recommend reading [this tutorial](http://www.catb.org/~esr/faqs/smart-questions.html) on how to ask a smart question.

Member Avatar for Trentacle
0
93
Member Avatar for saybabs

Please direct replies here: http://www.daniweb.com/software-development/csharp/threads/426133/csv-file-to-database

Member Avatar for deceptikon
0
210
Member Avatar for rhowell

> My theory is that those libaries are needed for those 'built-in' functions and that those libaries do not exist on my system. Yup. Your only two options are to find libraries that implement the functions being called, or simulate the functionality by writing definitions for those functions manually.

Member Avatar for rubberman
0
432
Member Avatar for firdousahmad

> how the compiler searchs for a file when we write fopen("filename","r"); It doesn't search, you give it a specific file name. As far as relative paths, that's fairly standard behavior in that the *system* (not the compiler) will attempt to open the specified file in the current working directory.

Member Avatar for deceptikon
0
120
Member Avatar for adam_k

What operating system are you using? I'm running Chrome on Windows 7 64-bit and selection seems to work as expected.

Member Avatar for Dani
0
434
Member Avatar for greatman05

An adapter is really nothing more than a wrapper around another class that exposes a specialized interface. So at its simplest, a stack might be implemented like so: template <typename T> class Stack { public: bool empty() const { return _data.empty(); } void push(T const& x) { _data.push_back(x); } void …

Member Avatar for greatman05
0
405
Member Avatar for triumphost

I can't reproduce the error because too many things are missing. Can you boil it down into a small and complete program that's compilable as-is? Also, what compiler are you using?

Member Avatar for deceptikon
0
499
Member Avatar for jnawrocki

> Remove conio.h and _getch and it should compile for you. If you can remove parts of a program without affecting it's functionality or usefulness, were those parts really needed in the first place? ;) But no, it won't compile for anyone who's not using Visual Studio. Even then, Visual …

Member Avatar for jnawrocki
0
277
Member Avatar for abrarsyed

Look into how qsort() works, as that's the solution for C. However, C is very inadequate for dynamic typing, so you'd probably be better off looking for a different implementation language or ditch the "accept any type" option in favor of something better suited to C.

Member Avatar for KenJackson
0
132
Member Avatar for dyl_ham

In proper socratic fashion I'll ask you this: what happens to an ifstream object when it goes out of scope?

Member Avatar for dyl_ham
0
1K
Member Avatar for new_developer

You'll want to convert both a and b to strings, concatenate them, then convert the result back to an integer. Here's an example using string streams: #include <iostream> #include <sstream> #include <string> using namespace std; int main() { int a = 4; int b = 5; ostringstream oss; oss << …

Member Avatar for TrustyTony
0
14K
Member Avatar for kandarpa

> sscanf(puppy,"%[^|]%f", &p, &num); Try this instead: sscanf(puppy,"%[^|]|%f", p, &num); You forgot to extract the pipe character. Not to mention that the address-of operator is unneeded on `p` because it's already a pointer to char.

Member Avatar for deceptikon
0
264
Member Avatar for ChrisHunter

I've committed a fix to our code repository. It should make it to production pending Dani's approval. Thanks for the report. :)

Member Avatar for Dani
0
178
Member Avatar for optimus_prime_1

You forgot to post the code. By the way, is this a code snippet for the benefit of others or do you have a question about the code?

Member Avatar for deceptikon
0
742
Member Avatar for nee_88

> Here, in the call to the function, what are we passing as an arguement, is p is here a char pointer or a char ** ?? In the first call the argument is `char*`. In the second call it's `char**`. An important difference to note is with multidimensional arrays. …

Member Avatar for deceptikon
0
119
Member Avatar for abrarsyed

The short answer is you can't. The long answer is you can if you aren't pedantic about it. An array can be copied by value by wrapping the array in a structure and then passing an instance of that structure. When the structure instance is copied, the array goes with …

Member Avatar for Trentacle
0
225
Member Avatar for warzaru

It seems to work on my end (noting that I removed readData() and built the vector manually). Can you post some sample data that exhibits the problem?

Member Avatar for Lucaci Andrew
0
326
Member Avatar for Mike Askew
Member Avatar for Dani
0
239
Member Avatar for triumphost

> First, why does this not cause a stack overflow? I'd wager that the empty function call was optimized away. You *might* be able to turn off all optimization switches in your compiler and get it to overflow. > Two, What is the difference between the two below? The first …

Member Avatar for mike_2000_17
0
108
Member Avatar for Sendy Hipo

> erm i learn new thing, its a bad idea to use "using directive" inside a class declaration, because this can leads to ambiguous functions/statements inside the main program. That argument only applies if you reuse standard library names, which generally isn't a good idea in the first place. While …

Member Avatar for Sendy Hipo
0
454
Member Avatar for bgraw

> how to write it :) Is this your question? If so, you'll need to put forth a little bit of effort. I doubt anyone is willing to write a ternary tree for you because you're too lazy to make an attempt.

Member Avatar for bakabozza
0
218
Member Avatar for poloblue

Gaack, I'm sorry. I accidentally killed your code when I changed this article from a code snippet to a discussion thread. Would you mind posting it again as a reply?

Member Avatar for poloblue
0
111
Member Avatar for AnnA.A

What's the logic for the path? Is it the shortest path between A and B? Longest? Ad hoc based on input?

Member Avatar for Despairy
0
90
Member Avatar for myk45

You pretty much nailed it for a simple class. It gets quite a bit more complex when construction, destruction, inheritance, polymorphism, and especially multiple inheritance enter the picture. A good book covering the topic is [this one](http://www.amazon.com/Inside-Object-Model-Stanley-Lippman/dp/0201834545).

Member Avatar for myk45
0
122
Member Avatar for sameerge

> Q1. Languagess are system software or application software? Neither. Languages aren't software at all, they're abstractions designed to simplify the task of humans giving instructions to a computer. A programming language is nothing more than a set of grammatical rules that, when consumed by a compiler or interpreter, represent …

Member Avatar for WaltP
0
219
Member Avatar for vivekgupta143

> Why dont we use '&' in the case of strings in function scanf ?? > > e.g. :- > > scanf("%s",date); > > here date is a character arraymeans string. Because date is already a pointer in this case. There's no need to add another level of indirection with …

Member Avatar for deceptikon
0
100
Member Avatar for sternone

The syntax for PHP is derived from the C family of languages, Ruby isn't. You'd feel more comfortable with PHP, but it's generally a good idea for programmers to have some familiarity with different language families.

Member Avatar for sternone
0
248
Member Avatar for Nikita Sachdev

9 times out of 10, a linker error means you failed to define something that was declared before it's usage. Very often this is due to a static class data member: class foo { static int bar; }; int foo::bar; // This external definition is required somewhere (ideally in a …

Member Avatar for jaskij
0
193
Member Avatar for daino

> Can you write a program in C++ and have another part written in C and compile them into a single executable file? Yes. The two would be compiled into object code separately, then linked together. However, that's not the hard part. The hard part is making sure that the …

Member Avatar for rubberman
0
262
Member Avatar for triumphost

> I'm writing it so that I don't have to worry about deleting anything everytime I allocate. While writing your own smart pointer is a good exercise, it shouldn't be preferred over the ones already available in C++11 and Boost. I'd recommend studying the interface for those and how they …

Member Avatar for rubberman
0
140
Member Avatar for VernonDozier

set_union() assumes that the output iterator points to a collection with enough existing space to hold all of the results. If you're planning on using an empty vector or have set_union() grow the vector then you'll want to do it through a back inserter.

Member Avatar for VernonDozier
0
384
Member Avatar for cereal

I was able to reproduce the issue on Chrome Beta 20.0.1123.27. Clearing the cache corrected it. If you're affected, please try clearing your browser's cache and let us know if the problem persists.

Member Avatar for Dani
0
230
Member Avatar for triumphost

> Is it possible to overload one operator more than once? Yes, but only if the parameter types are unique. Operator overloading is no different from regular function overloading in that the signature (not including the return type) must be different for overload resolution to be unambiguous.

Member Avatar for triumphost
0
2K
Member Avatar for Perry31

I'm going to go into pedantic mode for a bit. Apologies if either of you are offended in the process. > `#include <conio.h>` C is a widely portable language, which means it's possible to take code and compile it on a multitude of operating systems and compilers without any changes. …

Member Avatar for DeanMSands3
0
8K
Member Avatar for iAndrewMeyer

> numPerms\[ii] = str; `str` is a pointer, that pointer holds the address of `word` from main(). After RecursivePermute() runs to completion, every pointer in `numPerms` points to the same address. Given that you've already allocated memory to each element in main(), you can fix both the problem and the …

Member Avatar for VernonDozier
0
188
Member Avatar for vilas_tadoori

Well, you could take advantage of the way the numbers are patterned. Notice how your triangle fits perfectly if you replace everything less than or equal to N with asterisks, where N starts at 6: int j; int x = 6; for (int i = 1; i < 6; i++, …

Member Avatar for NormR1
0
998
Member Avatar for G_Waddell

I've wondered that as well, but if it were in Software Development I'm sure someone would ask why there's not a database subforum in Web Development. ;) Anyway, my conclusion was that it's just an artifact of history where Dani simply chose to put that subforum there instead of somewhere …

Member Avatar for G_Waddell
0
324
Member Avatar for harshm027

> When I use Chromium, I am unable to login. > Today I tried my luck with Firefox and it worked. > But I am not sure what the problem with Chromium is.. This is mostly for my own curiosity, but it could also benefit troubleshooting: have you tried Chrome …

Member Avatar for harshm027
0
144
Member Avatar for Patiodude

Some compilers have an option to rename the entry point, but I'd question its usefulness in all but the most niche cases. > And what, exactly, is the purpose of the main part, anyway? To provide an entry point into the program. That's really it. The C++ runtime has to …

Member Avatar for VernonDozier
0
189
Member Avatar for tensity

setw() is an absolute field width, not something based on tab stop boundaries, so you'd need to calculate the correct field widths for even alignment. You can also use the '\t' escape character to print a tab that will adhere to tab stop boundaries: cout << setw(23) << left << …

Member Avatar for tensity
0
125
Member Avatar for tubzz

Please provide evidence of having attempted to solve this homework question on your own.

Member Avatar for deceptikon
0
674
Member Avatar for cse.avinash

I'm not sure I understand the requirement. It looks like start and finish are related, in which case sorting by finish time would be more meaningful like this: #include <stdio.h> #include <stdlib.h> struct ElapsedTime { int start, finish; }; int compare_elapsed(void const* a, void const* b) { struct ElapsedTime const* …

Member Avatar for cse.avinash
0
97

The End.