User Profile

Collapse

Profile Sidebar

Collapse
Prasannaa
Prasannaa
Last Activity: Apr 7 '09, 07:22 AM
Joined: May 2 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • As of now, compilers requires the template definitions in the h file itself, if it is used in multiple translation units.So you need to move the template functions to the h file. That should get rid of the link error. You can declare/define the template functions in the cpp file, if you are going to use those functions only with in that translation unit.

    Prasannaa
    See more | Go to post

    Leave a comment:


  • Prasannaa
    replied to static function declaration and definition
    in C
    Hi,

    You need the static keyword only at the declaration. No need to have static
    keyword at the declartion or during the call.

    Thanks,
    Prasannaa
    See more | Go to post

    Leave a comment:


  • Prasannaa
    replied to converting month number to month name
    in C
    Hi,

    Another simple method. Since month names are not going to change, you can create a static array with month names and just index (after checking for bounds) the array with the number.
    Now it becomes a simple array index.


    Prasannaa
    See more | Go to post

    Leave a comment:


  • Hi ,

    Based on your comments, I think the problem is because.you are overwriting the memory of a variable using others. This will happen when an array is accessed out of its index, which may belong the next members memory.

    char arra[10];
    int i;

    arra[12] = 'a'; is changing the variable i;, So you may want to check the setmethods().

    Regards
    Prasannaa.
    See more | Go to post

    Leave a comment:


  • Prasannaa
    replied to Optional method arguments
    in C
    Hi,

    You can change your func signature as

    checkForWin(boa rd& gameBoard, player *opponent = 0);

    this way, you can pass in the player if needed(for the second use of the function). You can also use the following signature

    checkForWin(boa rd& gameBoard, player& opponent = player());

    but its not normally used, b'cos it creates an object (which may/may...
    See more | Go to post

    Leave a comment:


  • Prasannaa
    replied to Debugging in Visual C++ 2005 Express.
    in C
    Hi,

    On your project Properties menu, under Debugging ,
    there will be a command arguments sections. You can enter the command
    line line args here.


    Regards
    Prasannaa
    See more | Go to post

    Leave a comment:


  • Hi,
    There is no way to associate a particular ctor to a container.
    if you take a look at std::map help, the third arg is a comparison function
    which helps the container in sorting, it has nothing to with object creation.

    One more thing, When you use the map's[] operator , a default object is created(if not already present) and assigned to the key that you used as index, the assignment that you do...
    See more | Go to post

    Leave a comment:


  • Prasannaa
    replied to C# Method Call Help
    in C
    Hi,
    There is no such function called (in your code)
    UpdateBalanceDi splay(void/no args);
    You have declared UpdateBalanceDi splay(decimal) , which takes a decimal.
    I think you forgot to pass the value while calling the function.


    Regards
    Prasannaa
    See more | Go to post

    Leave a comment:


  • Hi
    I am also new to python.
    I tried your code, it works fine for me.
    (I use Python 2.5).

    Regards,
    Prasannaa
    See more | Go to post

    Leave a comment:


  • Hi,

    You can use lower_bound or upper bound to find the closest or exact
    element.Please note that in order to use these ,the
    container has to be sorted.(In your case it is, so you don't have to).

    Regards
    Prasannaa.
    See more | Go to post

    Leave a comment:


  • Prasannaa
    replied to Dynamic 2D array
    in C
    Hi,
    you have to prefix std::vector<std ::vector<T> >::const_iterat or with
    typename as
    Code:
    typename   std::vector<std::vector<T> >::const_iterator
    on both your declaration and definition.

    What would be more elegant is to typedef the const_iterator as

    Code:
     typedef typename std::vector<std::vector<T> >::const_iterator  const_iterator;
    and then start...
    See more | Go to post

    Leave a comment:


  • Prasannaa
    replied to string reverse
    in C
    Hi ,

    Another way is to use string.find(), and reverse() functions in a while loop.
    find the first space, reverse the sub str using reverse , now update the start
    with ++found, find the next space and repeat the logic till there is no space.

    Regards
    Prasannaa.
    See more | Go to post

    Leave a comment:


  • Prasannaa
    replied to C++ Subroutines
    in C
    Hi ,

    Since i am not aware of the precise context, I assume that you need all the other functions to use vatiables declared in main(). You can do so my moving the variables to a struct , declare the struct in main, and change those functions to take this struct as argument(pass by ref). I think should solve the problem.

    Regards,
    Prasannaa.
    See more | Go to post

    Leave a comment:


  • Prasannaa
    replied to Simple C# validation.
    in C
    Hi ,

    try this link
    http://msdn2.microsoft .com/en-us/library/system.windows. forms.keyeventa rgs.aspx

    Regards
    Prasannaa
    See more | Go to post

    Leave a comment:


  • Prasannaa
    replied to storing 2d array
    in C
    Hi ,

    Instead of arrays, you can use vectors and pairs.
    Something like the below
    ::Code removed per Posting Guidelines::
    Regards
    Prasannaa
    See more | Go to post
    Last edited by sicarie; May 4 '07, 02:29 PM. Reason: Violates Posting Guidelines

    Leave a comment:


  • Prasannaa
    replied to static array as a class member
    in C
    Hi ,

    The reason , why you don't get error
    when you declare "int a;" as "static int a;" is because you are not using it
    anywhere in the code, if u use it then you will get the link error.

    Regards
    Prasannaa.
    See more | Go to post

    Leave a comment:


  • Prasannaa
    replied to Inherit vector class
    in C
    Hi

    There sould not be any problems.
    The following code compiles fine.
    Post the error msgs that you got.

    Code:
    #include <vector>
    using namespace std;
    
    template<class T>
    class vector_plus : public vector<T>
    {
      public:
        vector_plus();
        void erase_item(const T& item)
        {
    	iterator itr= find(begin(), end(), item);
    ...
    See more | Go to post

    Leave a comment:


  • Prasannaa
    replied to Problem with templates
    in C
    Hi,
    try
    typedef typename std::list<T>::i terator my_iterator;

    Prasannaa
    See more | Go to post

    Leave a comment:


  • Prasannaa
    replied to Use a template with a class
    in C
    Hi,

    Since Stack is a template class it needs a Template Argument.
    Second, list and std namespace has to included.
    class List_Stack : public Stack<T>
    Code:
    #include<list>
    //using namespace std;
    
    template <class T>
    class Stack {
    	public:  
    		virtual void push(T c) = 0;
    		virtual char pop() = 0;
    };
    
    template <class T>
    ...
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...