Included library calls function from main.cpp

Started by
2 comments, last by Norman Barrows 7 years, 7 months ago

Hello! I was wondering if there's anyway I could do something like this:

Library.cpp


int main()
{
    init();
    
    while (true)
    {
        update();
        draw();
    }
}

main.cpp


#include <Library.hpp>

void init()
{
   //blah
}

void update()
{
    //blah
}


void draw()
{
    //blah
}

It that possible or will I have to figure something else out?

Advertisement
Sure, just declare the function(s) you want to call in a header that library.cpp includes, and implement them wherever.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

Oh wow! Thanks so much! I can't believe I didn't think of that :wacko:

you seem to have you filenames backwards.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

This topic is closed to new replies.

Advertisement