3,183 Posted Topics

Member Avatar for Prem_1

Somehow I suspect you're not providing nearly enough information for us to give you a helpful answer. However, as stated this can be done with a trivial function: double current_ratio(double asset, double liability) { return asset / liability; } That can be extended into a declaration and defnition using two …

Member Avatar for deceptikon
0
667
Member Avatar for karabomoeng

I'm going to go out on a limb and suggest that the problem is an unlicensed version of the "folder hider" software such that the feature you want isn't available after recent updates.

Member Avatar for Reverend Jim
0
147
Member Avatar for christinetom

Each node is just an anonymous variable that the pointer points to. It seems like your confusion is more about self-referential structures than anything. So let's take a look at a simple linked list: #include <iostream> struct node { int data; node *next; node(int data, node *next = nullptr): data(data), …

Member Avatar for christinetom
0
275
Member Avatar for phorce

Covariance only works within an inheritance hierarchy. What you seem to want is a variant type in general, which can be achieved using Boost::Any or Boost::Variant, depending on your needs. That said, what exactly are the criteria for selecting the type in your factory? This can change how feasible a …

Member Avatar for deceptikon
0
190
Member Avatar for David W

> If you want a simple and fool proof way for input handling consider taking everything in as strings and running your own checking functions on them for validity. For standard types provided by the language, end user programmers shouldn't be expected to validate or parse them unless they want. …

Member Avatar for deceptikon
0
468
Member Avatar for phorce

You could try Daniweb chat for such things. ;) However, I don't think this kind of question is unsuited to a thread, especially since you might get a large number of differing opinions and a very interesting debate out of it.

Member Avatar for deceptikon
0
191
Member Avatar for raaz999

> I have a code that when mouse hovers a button then it fires click event. I would strongly recommend against this approach because it's unconventional and surprising. If an application I used did this, I would stop using it post-haste and look for an alternative.

Member Avatar for Ketsuekiame
0
3K
Member Avatar for Ancient Dragon

> Huh? How could a downvote become invalid due to changes in technology? The answer may have been excellent 10 years ago, but as technology and techniques change it becomes outdated and bad advice. If posts aren't read in the context of their post date, I can easily see downvotes …

Member Avatar for Assembly Guy
0
330
Member Avatar for ram619

> ptr-p should return a address. But here its returning data ? Subtracting two pointers returns the difference between the addresses, not another address.

Member Avatar for ram619
0
205
Member Avatar for RascelleGrepo

> I want to allow only numbers (int & float data type) input. How will I do that? The usual and recommended approach is to simply allow the user to type anything and then throw errors if it doesn't match what you're expecting. For example with numbers only: #include <ios> …

Member Avatar for deceptikon
0
1K
Member Avatar for hg_fs2002

Arrays cannot be copied, but if you really want to do it with the assignment operator, you can wrap the array itself in a structure #include<stdio.h> typedef struct { int data[5]; } array; void foo(array b) { int i; for (i = 0; i < 5; i++) { printf("%d\n", b.data[i]); …

Member Avatar for rubberman
0
247
Member Avatar for Vish0203

> "the exe is not compatible...... make see whether you need 32 bit or 62 bit" Are you paraphrasing, or is that the exact message? Also, how are you running the generated executable?

Member Avatar for Vish0203
0
177
Member Avatar for avinash7

As a huge hint, here is a macro that calculates the number of leap years for a given year: #define LEAP_COUNT(year) ((((year) - 1) / 4) - (((year) - 1) / 100) + (((year) - 1) / 400))

Member Avatar for deceptikon
0
164
Member Avatar for leon.lashway

> there is no need for dump and all..simply u get a string using %s..that's it Okay, now type a first and last name. You introduced an error since the original code was retrieving a full line of input rather than a single word. Ideally one would use fgets() for …

Member Avatar for deceptikon
0
436
Member Avatar for Angelrawzz

You need to decide whether you want to use C-style strings or C++ std::string. If you want a C-style string, it's called like this: int main() { char s[] = "apples"; char a = 'p'; char b = 'd'; cout << "Before swap of Char : " << s << …

Member Avatar for deceptikon
0
617
Member Avatar for harde_1

The tree being "mono" is already an invariant as far as nodes go, you'll never have two nodes with the same key. However, you can check for the tree being "mono" with a simple traversal and a test to see if any of the counts are greater than 1 (which …

Member Avatar for deceptikon
0
309
Member Avatar for n1csaf3

You can pass a ref parameter in C++/CLI using the '%' operator, it corresponds to standard C++'s reference operator(&): int MediaMogul::readlist(String^% name) { name = "changed value"; return 0; }

Member Avatar for deceptikon
1
602
Member Avatar for Saqlainz

While I appreciate your willingness to share your knowledge, Daniweb's forum isn't a reference manual. If all you're going to do is post an extremely sub-par variant of MSDN, please stick to answering questions.

Member Avatar for deceptikon
-4
117
Member Avatar for nitin1

Yes, you can certainly discuss those things. Though the topic is rather broad, and in the case of "is it okay to do/say XYZ" the general advice stands: if you have to ask, it's probably not okay. p.s. The only way to feel comfortable in an interview is to not …

Member Avatar for jwenting
0
350
Member Avatar for kohkohkoh

Storage isn't an issue, and storing them as binary won't change the size unless the majority of the size is formatting of record data. The question you should be asking is "how do I need to access this data"? For example, if you're just storing the files and will read …

Member Avatar for kohkohkoh
0
186
Member Avatar for tanatos.daniel

Check your errors. For example, whenever opening a file fopen() returns NULL on failure: FILE *f=fopen(file,"w"); if (f == NULL) { perror("Error opening output file"); /* Whatever exit or recovery strategy you choose here */ exit(EXIT_FAILURE); } If nothing else you may get more useful information in the way of …

Member Avatar for tanatos.daniel
0
368
Member Avatar for nitin1
Member Avatar for ram619

Order of operations, my friend. `(int*)a + 1` converts `a` to a pointer to int, *then* increments it **as a pointer to int**. What you wanted, according to your expected output, was to increment `a` *first*, then convert to a pointer to int: static int *p[] = {(int*)a, (int*)(a + …

Member Avatar for ram619
0
231
Member Avatar for nathan.pavlovsky

> How can I do it with sprintf()? Before I posted here, I scoured the internet all over, and all the explanations for sprintf were to complicated. I couldn't understand. If AD's example above was too complicated, I'm not sure what to tell you, because that's as simple as it …

Member Avatar for nathan.pavlovsky
0
2K
Member Avatar for lalitha2294
Member Avatar for tanatos.daniel

Also keep in mind that if you need a destructor, you probably also need a copy constructor and copy assignment operator (and possibly a move constructor and move assignment operator for C++11). I'd also avoid a protected data member in favor of a private data member and public const getter. …

Member Avatar for deceptikon
0
409
Member Avatar for sireiz

The indexing works the same way since it's nothing more than an array of 2D arrays. If you add another dimension of 2, duplicate what you posted each with an index of 0 and 1: 000 001 010 011 100 101 110 111.

Member Avatar for Ancient Dragon
0
178
Member Avatar for nitin1

There are actually a number of problems with that function, though returning a pointer to a local variable is probably what the interviewer wanted.

Member Avatar for deceptikon
0
113
Member Avatar for tanatos.daniel

> I can't figure out what type of parameter should my addArticle() function have in order to work for this main. I would like to let the compiler choose if the object passed is a CBook or a CMagazine. Is that possible? Perhaps I'm missing something, but if you want …

Member Avatar for tanatos.daniel
0
449
Member Avatar for Labdabeta

> I see that a lot of people are already familiar with C++11 to the point that they don't think about it when they use its features. Is it now considered 'best practice' to use the new features? Best practice depends on your needs. If you don't need to conform …

Member Avatar for mike_2000_17
0
410
Member Avatar for riahc3

I take it you're going to air your dirty laundry every few months just to remind us that you're unhappy with the new system? > Every forum uses your regular [code][/code] but no, not Daniweb. Not every forum, just forums based around or inspired by vBulletin. Hop on over to …

Member Avatar for riahc3
0
1K
Member Avatar for johnappiah

Understand accounting, know how to develop software, define the features you want, and implement them.

Member Avatar for rubberman
0
114
Member Avatar for fsusem1nolez

> you'd think it wouldn't build correctly but I guess technically it was correct This is a key lesson with C++. Just because it compiles doesn't mean it's correct, either semantically where the language is concerned or logically in terms of the application's intended behavior.

Member Avatar for deceptikon
0
430
Member Avatar for nmakes

First and foremost, identifier names that are varying case from a keyword like CLASS, INT, or CHAR, are extremely bad ideas. I strongly suggest using something more informative. To answer your specific question, pointers to class types work *exactly* the same way as pointers to built-in types. For example, when …

Member Avatar for deceptikon
0
154
Member Avatar for nitin1

> do u think 1 hour is sifficient ? Certainly not, but as you're hopefully not trying to deceive the interviewer, that's not your problem, is it? ;) > 1.Why amazon ? Why not? > 2.what will you do if you get offer from google after getting offer from us …

Member Avatar for deceptikon
-1
210
Member Avatar for Labdabeta

There's a way to systematically convert a recursive algorithm to an iterative one, but unless you're dealing strictly with tail recursion, some form of stack data structure is still required. Do your contest requirements exclude the high probability of virtual memory on the machine being sufficient to contribute to the …

Member Avatar for Labdabeta
0
303
Member Avatar for Dani

It's not obvious that the check is a button or what it does. I suspect very few people have bothered to click on it.

Member Avatar for Dani
8
326
Member Avatar for ddanbe

Option 1 would be preferred in this case. In option 2 you're allocating a whole new data structure to hold the filtered results and also iterating the original list in its entirety once followed by the filtered results once. In option 1 you have what essentially boils down to a …

Member Avatar for Ketsuekiame
0
286
Member Avatar for Franze

Your description of the problem and solution seems dicey. Could you elaborate a bit on what this critical piece of code is so that it's easier to determine what IPC solutions would work best? Right now you basically have a race condition with your locking file, which is a bigger …

Member Avatar for Ketsuekiame
0
3K
Member Avatar for Frank_5

Ignoring for the moment that this is a horrible example of object orientation and brings into question whether you're qualified to be giving out examples as if you know what you're doing, what exactly is the benefit of an object oriented bubble sort here?

Member Avatar for mike_2000_17
0
4K
Member Avatar for dany12

I wouldn't say it's a favorite, but I'm cheap, and the best free IDE I've used so far has been NetBeans.

Member Avatar for diafol
0
191
Member Avatar for MonsieurPointer

> Thank you for your reply, but that is not the answer I was looking for. I suspect the answer you're looking for is unreasonable. A better solution is to fix your design such that you don't need to wade into the shithole of pointers to arrays. For example, using …

Member Avatar for MonsieurPointer
0
195
Member Avatar for nchy13

What problem are you having such that you need help? Simply saying "Any help is appreciated" is very broad. For example, I'd do something completely different; does throwing away your code and starting over constitute "help"?

Member Avatar for nchy13
0
825
Member Avatar for imBaCodes

At the moment, Baby Steps. Of all time, probably W Juliet or Day of Revolution.

Member Avatar for Bloodseeker
0
96
Member Avatar for حسنين_1

The rules don't change just because you're nesting a control structure: if (foo) { if (bar) { // Blah blah } } else { if (baz) { // Blah blah } else { // Blah blah } }

Member Avatar for deceptikon
0
82
Member Avatar for jandanielsaclolo

> Besides, it is not part of the standard and your code might not work with other compliers. Before each scanf(), put fflush(STDIN); to make sure the input stream is empty. Um...I hate to break it to you, but 1) C++ is case sensitive and STDIN is not a valid …

Member Avatar for jandanielsaclolo
0
257
Member Avatar for zahidhcy
Re: loop

> Actually the C coding standard often used does not allow declaring variables inside a 'for loop' ... It depends on which standard you're compiling for. Prior to C99 you cannot declare a variable in the initialization clause of a for loop. Starting with C99, you can. Note that prior …

Member Avatar for Unimportant
0
192
Member Avatar for Himanshu Chawla

> I have Not Studied about Pooling in ADO.NET and So I don't Know about the Concept of Pooling Then I guess you're not qualified to answer the question. Why should we help you cheat? > If Anybody can Solve It for me ? Honestly, I don't think any of …

Member Avatar for deceptikon
-2
139
Member Avatar for Lp_baez

Consider this simple example of clearing the input line on an invalid conversion: #include <ios> #include <iostream> #include <limits> using namespace std; int main() { int num; while (true) { cout << "Enter a number: "; if (cin >> num) { break; } cerr << "Invalid input\n"; // Clear the …

Member Avatar for David W
0
2K
Member Avatar for nchy13

> I thought that any change in pointer was reflected in main(). You can pass a reference to achieve that behavior. > Is same behaviour expected in C? Yes.

Member Avatar for deceptikon
0
167

The End.