Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8887875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:54:57+00:00 2026-06-14T21:54:57+00:00

I have a global assigned as a pointer to my window like this: globals.cpp

  • 0

I have a global assigned as a pointer to my window like this:

globals.cpp & globals.h has:

#include <SFML/Graphics.hpp>
sf::RenderWindow* window

Then in main.cpp i put:

#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
#include <map>
#include <string>

using namespace std;

#include "globals.h"

window(VideoMode( (800,600) , "Test") ); //line 22

How ever this appears to be incorrect. As i get this error:

main.cpp(22): error C2228: left of '.VideoMode' must have class/struct/union

What am doing wrong here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T21:54:58+00:00Added an answer on June 14, 2026 at 9:54 pm

    Maybe I’ve totally misunderstood the question, but why do you have the pointer defined in both the header and the source file? Seems to me you should do the following:

    In globals.h

    extern sf::RenderWindow *window;
    

    In globals.cpp

    sf::RenderWindow *window;
    

    In main.cpp

    window = new sf::RenderWindow( sf::VideoMode(800,600), "Test" );
    

    And don’t forget to delete window once you’re done with it.


    Also, I strongly urge you to replace the global pointer with

    std::unique_ptr<sf::RenderWindow> window;
    

    and initialize it as

    window( new sf::RenderWindow( sf::VideoMode(800,600), "Test" ) );
    

    Now you don’t need to worry about deleteing it!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Actionscript you can have global variables like this: var number : Number =
I have a global js file which has an ajax script. which is included
I have a global header and footer that has a Database connection and a
I have a global pointer variable char* pointer = new char[500]; /* some operations...
I have a template A which has several sublayouts and web controls assigned to
so I have this function which gets called multiple times during my program. //global
I have assigned a new Global hotkey to VS 2010/Options/Environment/Keyboard/OtherContextMenus.FSIConsoleContext.ResetSession But it seems to
I have global flags which enable/disable features. I'd like to inject some dependencies depending
I have a MySQL user, which we'll call Tom. Tom has global CREATE and
A quite simple and straightforward example. I have a window. It has CommandBindings set

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.