User Profile

Collapse

Profile Sidebar

Collapse
Shakje
Shakje
Last Activity: Apr 4 '07, 04:42 PM
Joined: Jan 14 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Shakje
    replied to Help in for, while and do-while loop
    in C
    For loops are the best way to do looping when you have a fixed number of iterations, but you can use while loops in the same way quite easily. All a for loop really does is include the stuff you have to do in the line you start it.

    while loops keep on executing everything between the braces while the condition in brackets is true. Eg:

    Code:
    int counter = 0;
    
    while(counter < 10)
    {
    ...
    See more | Go to post

    Leave a comment:


  • Shakje
    replied to Inheriting a template class
    in C
    Never mind, just being silly, if I initialise it in the constructor it should all be fine.

    If it comes down to it, I'll just have it as a private static with a getter only.

    Thanks for the reply banfa :)
    See more | Go to post

    Leave a comment:


  • Shakje
    replied to Inheriting a template class
    in C
    Just to clarify, the code has to be extra readable, I guess I could just use a void* and overload it as necessary I just thought this might be a bit more elegant if it works. Another related question, if I have say:

    Code:
    enum TYPE {  PT_NULL,
                          PT_PROCESS,
                          PT_VARIABLE,
                          etc };
    
    static const TYPE m_type = PT_NULL;
    ...
    See more | Go to post

    Leave a comment:


  • Shakje
    replied to Help in for, while and do-while loop
    in C
    Code:
    #include <iostream>
    using namespace std;
    
    int main (void)
    {
    int i, j;
    for(i=1; i<=10; i++)
      {
       for(j=1; j<=i; j++)
          cout << j;
       cout << endl;   // ** you needed this!
      }
    return 0;
    }
    http://www.devx.com/tips/Tip/14184

    If you're doing lots of couts as in this case, it's better to get into...
    See more | Go to post

    Leave a comment:


  • Shakje
    started a topic Inheriting a template class
    in C

    Inheriting a template class

    Ok, quick question. I want to create a base class really just to use in a polymorphic vector, but since there will be generic stuff in there I want there to be a bit of functionality. Now, there's going to be a pointer in there, but depending on the inherited class, the type of pointer could change. I was wondering if it was possible to make the base class a template class, and specify the template when I inherit. If that makes no sense, see below....
    See more | Go to post
No activity results to display
Show More
Working...