User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
DaniWeb is a massive community of 427,048 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,562 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Showing results 1 to 40 of 500
Search took 0.05 seconds.
Posts Made By: vijayan121
Forum: C++ 14 Days Ago
Replies: 6
Views: 197
Posted By vijayan121
Re: wired knapsack...

the general knapsack problem and the subset sum problem are NP-hard, but not NP-incomplete. so there are no polynomial-time algorithms. but it is one of the easy NP-complete problems to solve.

it...
Forum: C++ 14 Days Ago
Replies: 11
Views: 354
Posted By vijayan121
Re: Const Question - Why is this happening?

this is nothing specific to constructors or passing parameters to functions.
it is just the application of the C++ rules for resolving a call to an overloaded function.
#include <iostream>

void...
Forum: C++ 16 Days Ago
Replies: 2
Views: 104
Posted By vijayan121
Re: a few questions about C++ source code

> #pragma - what does it mean
to understand what #pragma is see: http://msdn.microsoft.com/en-us/library/d9x1s805(vs.71).aspx
for the specific #pragma directives that are in your code, refer to your...
Forum: C++ 16 Days Ago
Replies: 2
Views: 98
Posted By vijayan121
Re: Container Adapter Confusion

have each of the two stacks to store a reference to a std::deque.
initialize them to refer to the same std::deque.
write a wrapper class to hold the two stacks.

template< typename T > struct...
Forum: C++ 16 Days Ago
Replies: 9
Views: 218
Posted By vijayan121
Re: Fast Conversions

writing a convert function (with construction and destruction of a stringstream each time it is called) would give more maintainable code. even in this case, the performance seems to be...
Forum: C++ 16 Days Ago
Replies: 9
Views: 218
Posted By vijayan121
Re: Fast Conversions

only because the language the OP is using ( MessageBox::Show ) is C++/CLI (not ISO C++).
and purely managed will not give anywhere near native performance.
Forum: C++ 16 Days Ago
Replies: 7
Views: 154
Posted By vijayan121
Re: help with stream files

in adition, change int size = 100; to const int size = 100;
size of an array must be a constant known at compile time.
Forum: C++ 16 Days Ago
Replies: 9
Views: 218
Posted By vijayan121
Re: Fast Conversions

> What I look for now is a fast way to convert from double to char*
> I have a problem to find this conversion.

a. compile C++ source to generate native code, not IL that is interpreted at run-time....
Forum: C++ 25 Days Ago
Replies: 4
Views: 274
Posted By vijayan121
Re: Constructor function call problem

consider using the std::tr1 polymorphic function wrappers. this would allow using free functions, member functions and function objects in a polymorphic way.

if your compiler does not ship with tr1,...
Forum: C++ 25 Days Ago
Replies: 7
Views: 269
Posted By vijayan121
Re: template function overloading

> But I still find it ackward, that there are no possibility to do it.
> I can handle special cases when, I have different INPARS as long as the method is void.
> But it's not possible to do it when...
Forum: C++ 25 Days Ago
Replies: 2
Views: 107
Posted By vijayan121
Re: Need help using shared_ptr

a std::tr1::shared_ptr cannot correctly hold a pointer to a dynamically allocated array. AFAIK, there is no such smart pointer in tr1.
you could use boost::shared_array (tr2) instead....
Forum: C++ 26 Days Ago
Replies: 14
Views: 444
Posted By vijayan121
Re: this pointer

> the self-assignment test does not work well in class hierarchies either,
> even with use of boost::addressof().

it is unlikely that using value semantics on object-oriented types is something...
Forum: C++ 26 Days Ago
Replies: 4
Views: 203
Posted By vijayan121
Re: Rounding function

perhaps the easiest way is to use the iostream formatted output facilities:
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>

int main()
{
double a = 2.5632, b = 2.5652 ;
Forum: C++ 26 Days Ago
Replies: 8
Views: 264
Posted By vijayan121
Re: Arguments and strings

a little less verbose, and a little more efficient:
#include <vector>
#include <string>

int main ( int argc, char** argv )
{
std::vector< std::string > arguments( argv, argv+argc ) ;
}
Forum: C++ 26 Days Ago
Replies: 14
Views: 444
Posted By vijayan121
Re: this pointer

>> The above is common practice, but it is easily broken.
>> Imagine, for example, a class that supports its own operator&() ...
>> The most useful way I've found to do an assignment operator is;...
Forum: C++ 26 Days Ago
Replies: 9
Views: 278
Posted By vijayan121
Re: can stdio.h be in one program with iostream.h?

for the predefined streams, it's safe to mix C stdio and C++ iostreams. you can safely use stdin and std::cin in the same program; the C++ Standard guarantees that it will work the way you would...
Forum: C++ Aug 31st, 2008
Replies: 1
Views: 150
Posted By vijayan121
Re: Problem with destructor

> As a destructor releases memory for an object ...
a destructor does not release memory. it deinitializes an object and after it executes, what is left is uninitialized memory (earlier occupied by...
Forum: C++ Aug 31st, 2008
Replies: 8
Views: 596
Posted By vijayan121
Re: shift (bitshift) through char array

> i would like to avoid doing 4 times 2 shift for each char.
> For each char i do 4 shift operations and 4 bitwise AND's, thats 8 bitwise operations.

you can reduce it to just 4 AND operations by...
Forum: C++ Aug 29th, 2008
Replies: 7
Views: 183
Posted By vijayan121
Re: Simple Source Control

also have a look at codeville http://codeville.org/
it is one one of the easiest to use.
Forum: C++ Aug 29th, 2008
Replies: 6
Views: 235
Posted By vijayan121
Re: Does it need a copy constructor and an operator= for a class which have array mem

you can answer this yourself if you write a small test program and run it. for example:
#include <iostream>

struct A
{
A() { std::cout << "A::default constructor\n" ; }
A( const A& ) {...
Forum: C++ Aug 28th, 2008
Replies: 3
Views: 191
Posted By vijayan121
Re: Design Problem: Dealing with multiple time frames

> Does it make sense to write a virtual method in the templated base class
> in order to force derived classes to have an appropriate addelement() method?
no. the polymorphism provided by templates...
Forum: C++ Aug 28th, 2008
Replies: 15
Views: 935
Posted By vijayan121
Re: Array with Variable Size in a Structure

measurements for the same snippet (3 each) for the microsoft compilers:

compiler: VC++ 9.0 (Express 2008)
optimizations: /Ox /Ob2 /Oi /Ot /Oy /GT /GL
processor: Intel Pentium M 1.86 GHz

c array:...
Forum: C++ Aug 28th, 2008
Replies: 3
Views: 191
Posted By vijayan121
Re: Design Problem: Dealing with multiple time frames

if you absolutely need a base class Chart (with virtual functions), a hack would be to overload the AddElement function.

i would prefer using templates for your containers as suggested by Narue in...
Forum: C++ Aug 27th, 2008
Replies: 15
Views: 935
Posted By vijayan121
Re: Array with Variable Size in a Structure

valarrays were introduced with the idea that it might encourage C++ compiler developers for vector processors to implement them as built-in types (the compiler could emit code to optimize the use of...
Forum: C++ Aug 25th, 2008
Replies: 6
Views: 239
Posted By vijayan121
Re: Changing the Access Specifier in Virtual Functions

Derived d;
Base *p = reinterpret_cast< Base*>(&d);
> I found that this is also legal--

it will compile.
it will work correctly if and only if the anonymous base class sub-object is at an offset of...
Forum: C++ Aug 25th, 2008
Replies: 9
Views: 279
Posted By vijayan121
Re: algorithmic problem...

any 3-combination of the N-set would consist of numbers at 3 different positions in the array; you could choose positions i,j,k out of these three such that i<j<k holds.

so doesn't the problem...
Forum: C++ Aug 24th, 2008
Replies: 3
Views: 181
Posted By vijayan121
Re: Search Function Troubles

> Could it be because i am entering the string 'key' with spaces?
yes
> how would i fix it?
use std::getline
http://www.cppreference.com/cppstring/getline.html
Forum: C++ Aug 23rd, 2008
Replies: 3
Views: 399
Posted By vijayan121
Re: union vs reinterpret_cast<>()

> Is there any real different between using an union between two types and a reinterpret_cast between two types
yes, there are quite a lot of differences.
a union reinterprets the layout of memory...
Forum: C++ Aug 21st, 2008
Replies: 3
Views: 248
Posted By vijayan121
Re: c++ - runtime check failure - what's wrong with this code ?

if your idea was to have a code sample which will help you understand how virtual function calls are implemented by the microsoft compiler:
#include <iostream>

#if defined(_MSC_VER) && (_MSC_VER >=...
Forum: C++ Aug 18th, 2008
Replies: 7
Views: 291
Posted By vijayan121
Re: "Taking an address"

see IS 9.4.2/4


GCC is conforming. static constant member object is 'used' (in main) and, therefore, has to be defined.

the main issue here is that if you take the address, the static object has...
Forum: C++ Aug 18th, 2008
Replies: 4
Views: 206
Posted By vijayan121
Re: Understanding binary data and algorithms--

Stan Lippman's Inside the C++ Object Model
http://www.amazon.com/Inside-Object-Model-Stanley-Lippman/dp/0201834545
Forum: C++ Aug 18th, 2008
Replies: 2
Views: 222
Posted By vijayan121
Re: geany and tags

http://geany.uvena.de/manual/0.14/index.html#tags
Forum: C++ Aug 15th, 2008
Replies: 13
Views: 558
Posted By vijayan121
Re: easist way to find out # of lines in a text?

> cat my_file.txt | grep ^ | wc -l
Forum: C++ Aug 14th, 2008
Replies: 3
Views: 279
Posted By vijayan121
Re: Reading keyboard from background process

use sockets (or pipes) to communicate keystrokes from one process to the other.
Forum: C++ Aug 14th, 2008
Replies: 6
Views: 223
Posted By vijayan121
Re: My class is not a modifiable lvalue?

Point B(); is the declaration of a function called 'B' which takes no arguments and returns a Point.
modify to Point B ; and you have the definition of a variable called 'B' which is of type Point...
Forum: C++ Aug 9th, 2008
Replies: 6
Views: 349
Posted By vijayan121
Re: Pointers to Template class without specified Type

the typical work around (as exemplified by the standard library containers and function objects) is to have the generic type announce dependent types via suitable typedefs.
#include...
Forum: C++ Aug 8th, 2008
Replies: 2
Views: 170
Posted By vijayan121
Re: Need help with cards project...

to just draw 52 cards in random order without duplicate draws, just fill an array/vector of size 52 with values [1,52] and do a std::random_shuffle on it.
to make 52 draws, marking/discarding...
Forum: C++ Aug 8th, 2008
Replies: 7
Views: 356
Posted By vijayan121
Re: Review: small recursive code

to reproduce the white spaces in the original in the reversed sentence:
#include <string>
#include <algorithm>
#include <iterator>
#include <iostream>
#include <ctype.h>

template< typename...
Forum: C++ Jul 19th, 2008
Replies: 1
Views: 263
Posted By vijayan121
Re: problem with template of a generic datatype

the error is this: error C2993: 'float' : illegal type for non-type template parameter 'zero'
non-type template parameters are restricted to
a. constant integral values (including enumerations)
b....
Forum: C++ Jul 18th, 2008
Replies: 5
Views: 475
Posted By vijayan121
Re: calculate the amount of heap memory

> Windows heap is not the same thing as CRT heap

and to complicate matters, there may be several win32 heaps (and several CRT heaps) in a process.
if an exe or shared object (DLL) is linked with...
Showing results 1 to 40 of 500

 
All times are GMT -4. The time now is 3:37 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC