2,898 Posted Topics

Member Avatar for Learner010

Printing in Unix/Linux would usually go through low-level utilities such as `lpr` and `lpq`. You don't have to make a postscript file if you just want to print a simple text file (postscript files is what you need for general fancy graphics, e.g., formatted text and images, and that is …

Member Avatar for Ancient Dragon
0
229
Member Avatar for Frank_5

If you don't have a question and this is just a code snippet, then just say so, I'd be happy to turn the post into a code snippet. About the code though, the one thing that really caught my eye was this statement that: "Note: it is not advisable to …

Member Avatar for surajsokasane
0
10K
Member Avatar for carbonfinger

The problem has nothing to do with the typedef or type of your function pointer. The type of the pointer returned by GetProcAddress is `void*`, and then you cast it to what it is supposed to be. In other words, the information about what kind of function is in the …

Member Avatar for mike_2000_17
0
298
Member Avatar for glao

> Does this mean , that I am copying `One_mat_` (which I am casting it as a `mymat3*` ) to `One_mat` which is defined as a `mymat3` matrix ? No, you are only making a copy of the pointer. The cast from `float*` to `mymat3*` causes the pointer `One_mat_` to …

Member Avatar for glao
0
170
Member Avatar for Warrens80

We don't have Taco Bell here. It's because of consumer protection laws against false representation. Basically, you cannot sell a "beef taco" if you cannot show that it actually contains beef. That's why Taco Bell (and a few other american chains) don't exist in Quebec. That said, if I'm south …

Member Avatar for mike_2000_17
0
468
Member Avatar for Labdabeta

Well, first of all, the two options are not mutually exclusive, there is not problem with providing both a factory function (create) and a polymorphic cloning function, it is, in fact, very common. Something like this: class Object { public: // NEVER FORGET THE VIRTUAL DESTRUCTOR!!! virtual ~Object() { }; …

Member Avatar for Labdabeta
0
257
Member Avatar for charlie.puzjak

The main program is a function. The question makes no sense. The alternatives: "within a function" *instead of* "within a function". You would open / close a file within any function for the same reason that you would open / close a file with the main function, i.e., because you …

Member Avatar for mike_2000_17
0
44
Member Avatar for programmer76
Re: 2020

> Knock out the satellites and all communications Easier said than done, there are far so many satellites that a large number of satellites could be "knocked out" without really compromising the whole system. Global telecommunication systems are massively redundant by design, there aren't really any single points of failure …

Member Avatar for ddanbe
0
383
Member Avatar for Xantipius

> sugar should be avoided. That might be hard, because sugar (in all its forms) form roughly 75% of the total mass of food you eat. This is no accident. The main reason to eat is to get energy, and the most effective source of energy is sugar. Now, by …

Member Avatar for jwenting
0
366
Member Avatar for castajiz_2

I still remember the good old days (only a few years ago), when any given search on a devel problem would result in a number of results from different sites (forums and mailing-lists), and when SO and Daniweb were more or less as likely to hit on searches. Now, it …

Member Avatar for Warrens80
0
292
Member Avatar for Dearden

These stereotypical "welfare queens" do exist, but they are a tiny fraction of the whole, a very tiny fraction. Right-wing rhetorics keep painting the entire population receiving gov. benefits as all being welfare queens / kings, exactly as you've painted it. The reality is, if you were to "solve" that …

Member Avatar for Ancient Dragon
0
844
Member Avatar for cambalinho

I don't think that MACROs can be wrapped in parentheses. The rules that the pre-processor works by are far simpler and crude than the rules by which the compiler works. The pre-processor is just a simple parser, a find-and-replace type of parser. So, the MACRO definition should be something like …

Member Avatar for Ancient Dragon
0
224
Member Avatar for HiHe

I use mostly public transit. In a big city, or when being a student, it is the most convenient means of transportation. I have a driver's license and occasionally borrow a car for trips that require it. But mostly, having a car is a hassle where I live. Most things …

Member Avatar for pixelsoul
2
181
Member Avatar for can-mohan

The standard solution to this is to use an associative container to store the list of numbers. One obvious option is to use `std::set` which relies on a binary search tree and will achieve look-up times of `O(log(N))`, as is typical of binary search trees. In your case, however (numbers …

Member Avatar for mike_2000_17
0
387
Member Avatar for VBOI

Just use [fprintf](http://www.cplusplus.com/reference/cstdio/fprintf/) instead of printf. You use fopen and fclose to open and close the file (with a `FILE*` handle).

Member Avatar for Nutster
0
3K
Member Avatar for Labdabeta

There are a few minor issues to begin with: virtual bool onEvent(Event e)=0; .. const Object &o .. o.onEvent(e); This is not going to compile because the member function `onEvent` is a non-const member, and the object `o` is a const object. You will need to choose between having a …

Member Avatar for Labdabeta
0
311
Member Avatar for salah_saleh

The closest you can get is probably something like this: class Data { // .... private: static const double* getInitValues() { static const double arr[] = {1.0,4.0,5.0}; return arr; }; public: Data() : V(std::vector<double>(getInitValues(), getInitValues() + 3)) { }; }; But frankly, I don't see the point of going through …

Member Avatar for salah_saleh
0
352
Member Avatar for christinetom

The two good reference sites are: http://www.cplusplus.com/reference http://en.cppreference.com/w/ There are also some downloadable versions of these as compressed help files (chm or qch) for local viewing (downloaded). I'm not sure what the best "hard copy" reference could be.

Member Avatar for mike_2000_17
0
384
Member Avatar for diafol
Member Avatar for Learner010

This truth table looks more like `( (NOT p) OR q )`. Or, it could be `if p then q else TRUE`.

Member Avatar for Learner010
0
90
Member Avatar for catastrophe2

> as a beginner, i managed to do this much (85%) and i am facing the problems of "Cannot find or open the PDB file." PDB files are files that are specific to Visual Studio projects. This is a problem with setting up your C++ project. Are you able to …

Member Avatar for catastrophe2
0
226
Member Avatar for catastrophe2

Welcome to Daniweb! I'm glad to welcome another C++ apprentice! (btw: I'm one of the main C++ gurus here) > i made an account here, in which i was able to post a question i had a bout a project for grading program, then i received email of required activation …

Member Avatar for catastrophe2
0
216
Member Avatar for cambalinho

As far as I know, the standard does not provide a specialization of `std::function` for "variadic functions" (also called "variable argument functions", or just var-arg functions). When you use the ellipses alone (not part of a variadic template syntax), it declares a variadic function, which is a special kind of …

Member Avatar for Ancient Dragon
0
7K
Member Avatar for cambalinho

What deceptikon said. In addition, I want to mention that this deduction of the template arguments is also the reason for having the `make_foo` functions to create class templates in a way that avoids explicitely listing the template arguments. What you would do is this: template <typename A> class test …

Member Avatar for cambalinho
0
388
Member Avatar for asif49

Obviously, people who commit murder ought to be prosecuted, and if a site receives footage or pictures of a real murder, then the site owners must report the footage to the appropriate authorities, otherwise, they are being complicit in the act and/or are obstructing justice (depending on jurisdiction). That said, …

Member Avatar for Ancient Dragon
0
870
Member Avatar for Ancient Dragon

I have never needed a car (living abroad and/or in a big city), except for borrowing or renting on occasions. The closest I got to owning a car was having custody, for one summer, of my brother's [1973 Toyota Celica](https://www.google.com/search?site=&tbm=isch&source=hp&biw=1072&bih=931&q=toyota+celica+1973&oq=toyota+celica+1973&gs_l=img.3..0l2j0i24l6.3119.9026.0.9267.20.14.1.5.5.0.179.1024.12j2.14.0....0...1ac.1.29.img..0.20.1057.1ungVRWsdTs), one of only three that were still in driving condition …

Member Avatar for GrimJack
0
395
Member Avatar for cambalinho

The problem is that you cannot run code in the global scope. The global scope is only for declarations or definitions, not for expressions (executing code). You have to move your setting for the Printed functor in the main function: #include <iostream> #include <string> #include "events.h" using namespace std; class …

Member Avatar for mike_2000_17
0
235
Member Avatar for pritaeas

I see the same problem (the username spilling over under the faint line) on my browser: Chromium in Linux(Kubuntu).

Member Avatar for pritaeas
1
226
Member Avatar for sris20013

Read [this tutorial](http://www.daniweb.com/software-development/cpp/tutorials/373787/beginning-c0x-making-a-raii-class) and you'll understand what the problem is with that code.

Member Avatar for Jamblaster
0
132
Member Avatar for Labdabeta

The way this is done is quite simple. It's all a matter of creating an interface (i.e., set of functions or classes) that is not specific to any particular platform. Then, you create an implementation that fulfills that interface for each platform you want to support in a way that …

Member Avatar for Labdabeta
0
355
Member Avatar for Labdabeta

Yeah, the most common use for static member functions is for factory functions, whether it is a straight-up "Create()" function to create an object of the class, or whether it is for a set of factory functions like "fromString" and stuff (i.e., Java-style conversion functions, when people are not familiar …

Member Avatar for mike_2000_17
0
204
Member Avatar for WEB-REPORTER

> Sorry, you're not allowed to do that. Try begging Dani for permission or participating more in the community to gain additional privileges. This site has a few restrictions for completely new members. These are designed to prevent spam and spam-bots. As any other popular forum site, spam is a …

Member Avatar for diafol
-8
318
Member Avatar for VUEKID

You have to iterate through the elements of the vector and output each string to the file. Here's one way: std::ofstream file_out("filename.txt"); std::copy(v.begin(), v.end(), std::ostream_iterator<std::string>(file_out, "\n")); Here's another: std::ofstream file_out("filename.txt"); for(const auto& s : v) file_out << s << std::endl; Here's another: std::ofstream file_out("filename.txt"); for(auto it = v.begin(); it != …

Member Avatar for mike_2000_17
0
2K
Member Avatar for Girija_1

Here is what I think is happening: thread-1 thread-2 LOCK(READ) read numDBs == X UNLOCK(READ) YIELD ---> LOCK(READ) read numDBs == X UNLOCK(READ) LOCK(WRITE) create DB: "Y_server_fwd_X" result <- getDB("Y_server_fwd_X") UNLOCK(WRITE) return result LOCK(WRITE) <--- YIELD create DB: "Y_server_fwd_X" get DB("Y_server_fwd_X") result <- getDB("Y_server_fwd_X") UNLOCK(WRITE) return result As you can …

Member Avatar for mike_2000_17
0
134
Member Avatar for Richard_10

The operator `--` is just the decrement operator, i.e., the opposite of `++`.

Member Avatar for mike_2000_17
0
293
Member Avatar for cambalinho

I think what you should use is the `std::thread` class, [see docs here](http://www.cplusplus.com/reference/thread/thread/). You would get the following: #include <process.h> #include <string> #include <thread> using namespace std; void SetCaretPosition (int x, int y) { COORD coord; // coordinates coord.X = x; coord.Y = y; // X and Y coordinates SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), …

Member Avatar for cambalinho
0
466
Member Avatar for priyanka.choudhary.90038

There are really only three options (in C++03, pre-C++11) to pass a parameter: by value, by reference or by const-reference. In the case of the copy-constructor, you cannot pass the parameter by value because to be able to do the copy (of the passed object), you need a copy-constructor, so …

Member Avatar for deceptikon
0
1K
Member Avatar for Vasthor

You should just use the initialization list instead: Screen::Screen(pos ht, pos wd) : cursor(0), height(ht), width(wd), contents(ht*wd, ' ') { } Screen::Screen(char c, pos ht, pos wd) : cursor(0), height(ht), width(wd), contents(ht*wd, c) { } // and default constructor (not required, but useful in general): Screen::Screen() : cursor(0), height(0), width(0), …

Member Avatar for tinstaafl
0
296
Member Avatar for saurav2007

Well, I have to correct the correction because what AD said is wrong. Local variables (defined in a function) with static storage duration (with `static` keyword) are created and initialized the first time control flows over that code (i.e., the first time the function is called). MandrewP was entirely correct. …

Member Avatar for Ancient Dragon
0
280
Member Avatar for Suzie999

For pre-C++11 compilers, i.e. C++03 compilers, you should use the Boost libraries, which is where all the standard library additions came from, and will likely come from in the future. In this case, the [Boost.Thread](http://www.boost.org/doc/libs/1_54_0/doc/html/thread.html) library is what you are looking for. However, I doubt that your idea is really …

Member Avatar for rubberman
0
739
Member Avatar for glenwill101

I think you need quotes around the whole thing: system("del \"%APPDATA%\\Microsoft\\Windows\\Start Menu\\*.vbs\""); That's the way to deal with that (when there are spaces anywhere in the file-path).

Member Avatar for tinstaafl
0
155
Member Avatar for lightdshadows

@naysa: Don't hijack an old thread like this. You should make a new thread to ask your question. And don't forget to show some efforts of your own towards solving your problem. We don't just provide ready-made answers to people's homework assignments.

Member Avatar for mike_2000_17
0
1K
Member Avatar for josephwakiro

First, if this is a C problem, you should have posted it in the C forum. So, please tell us if it is, in which case, it can be moved to the appropriate forum. Second, we don't just solve people's assignments / exercises for them. You have to show that …

Member Avatar for morad jbilo
0
167
Member Avatar for cppgangster
Member Avatar for cambalinho

When people say that C++ isn't a real OOPL, they mean one of two things: (1) C++'s implementation of OOP mechanisms (inheritance, virtual functions, etc..) is not "pure" OOP, or not pure enough. (2) C++ is a multi-paradigm language, and OOP just happens to be one of the main paradigms …

Member Avatar for cambalinho
0
390
Member Avatar for skyyadav

Here is a basic function object: struct greater_than { bool operator()(int a, int b) const { return a > b; }; }; and the sort call just becomes: sort(v.begin(), v.end(), greater_than()); where `greater_than()` just creates the function object that is passed to the sort function.

Member Avatar for mike_2000_17
0
276
Member Avatar for can-mohan

The C++ standard says this at section 11.3/7: > Such a function is implicitly inline. **A friend function defined in a class is in the (lexical) scope of the class in which it is defined**. A friend function defined outside the class is not (3.4.1). This means that you can …

Member Avatar for can-mohan
0
245
Member Avatar for nitin1

> Each year your salary will be increased by some 8-10% Yeah, right. I want to meet your employer. Yearly raises are more towards the 1-3% range. > after 30 years of life, what exactly we have in our hand ? Bank balance and experience of work in that company? …

Member Avatar for BigPaw
0
225
Member Avatar for can-mohan

Moschops is correct, you are "protecting" the wrong part of the code. What could be subject to a race condition is the decision about whether to create the Singleton object or not. The creation of the object itself is not the problem. This would seem to suggest that the correct …

Member Avatar for mike_2000_17
0
4K
Member Avatar for cambalinho

On most systems, there are a number of different accessible clocks, some more precise than others. And the C++11 standard reflects that with the use of `std::chrono::system_clock::now()` and `std::chrono::high_resolution_clock::now()`. The actual precision of those clocks is dependent on the system. I'm afraid Ancient Dragon's statement is somewhat out-dated. For a …

Member Avatar for cambalinho
0
419

The End.