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

  • SEARCH
  • Home
  • 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 6186487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:53:48+00:00 2026-05-24T01:53:48+00:00

Hey i’m getting this odd error when I leave the namespace sf{ declaration in

  • 0

Hey i’m getting this odd error when I leave the namespace sf{ declaration in the later code:

1>c:\libraries and headers\sfml\sfml-1.6-sdk-windows-vc2008\sfml-1.6\include\sfml\graphics\body.h(70): error C2989: 'sf::Body' : class template has already been declared as a non-class template
1>c:\libraries and headers\sfml\sfml-1.6-sdk-windows-vc2008\sfml-1.6\include\sfml\graphics\body.h(11): error C3856: 'sf': class is not a class template

The code worked fine when it wasn’t a template class for the past 3 weeks, With the same sf::Body class name; i just recently changed it to make it more flexible. Can i not declare a template class inside a namespace or what?

Here’s the code:

#include <SFML/Graphics.hpp>
#include <vector>
#include <math.h>
#include <cmath>

namespace sf{ //when i take this out and the closing bracket the code runs fine

    template<typename drawable>     
class Body : public sf::Drawable{ 

    private:
        sf::Vector2f MoveVal;
        std::vector<drawable> Drawables;

    public:
        Body(const Vector2f& Position = Vector2f(0, 0), const Vector2f& Scale = Vector2f(1, 1), float Rotation = 0.f, const Color& Col = Color(255, 255, 255, 255)){
            SetPosition(Position);
            SetScale(Scale);
            SetRotation(Rotation);
            SetColor(Col);};

// Overide Drawable Functions To Detect any Movement
        void SetX(float X){
            MoveVal.x += X - GetPosition().x;
            Drawable::SetX(X);};

        void SetY(float Y){
            MoveVal.y += Y - GetPosition().y;
            Drawable::SetY(Y);};

// Regular Functions
        void AddObject(drawable& Object){
            Object.Move(GetX(),GetY());
            Drawables.push_back(Object);};

        void DestroyObject(unsigned short Index){
            Drawables.erase(Drawables.begin()+Index);};

        void Clear(){
            Drawables.clear();};

        drawable& GetObject(unsigned short index) 
            {return Drawables[index];};

        unsigned int GetNumbObjects() 
        {return Drawables.size();};

        void Draw(sf::RenderTarget& target){
            for(unsigned short I=0; I<Drawables.size(); I++){
                //Body offset
                Drawables[I].SetPosition( 
                    Drawables[I].GetPosition().x + MoveVal.x,
                    Drawables[I].GetPosition().y + MoveVal.y);
            }                                                   // TODO: add tint based on overall Body Color

            target.Draw(*this); 

            //Reset all the Change Values
            MoveVal.x=0;
            MoveVal.y=0;
        };

        void Render(sf::RenderTarget& target) const{
            for(int I=0; I< Drawables.size(); I++)
                Drawables[I].Draw(target);
        };
};// Body Class

} //namespace sf
  • 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-05-24T01:53:48+00:00Added an answer on May 24, 2026 at 1:53 am

    The two most likely candidates based on your information are that Graphics.hpp has mismatched { } or that you had a forward declaration of class Body without marking it a template.

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

Sidebar

Related Questions

Hey I am getting this error: error: conversion to non-scalar type requested Here are
Hey I am getting index out of bounds error in my code. From Activity:
hey guys I have the follow code in js: $(document).ready(function(){ $(.replyLink).click(function(){ $(#form-to-+this.id).html(htmlForm()).toggle(500); return false;
Hey there stack overflow enthusiasts. I am getting this mixed content warning in Internet
Hey guys I'm running this code in Android: public ServiceServer(String serverName) { this.serverName =
Hey all, I'm using this code to change my sIFR (version 3) H1 and
Hey all, my Computational Science course this semester is entirely in Java. I was
Hey, in the Programming Pearls book, there is a source code for setting, clearing
Hey so I've been searching around for this topic and couldn't find a whole
Hey all. I've been been trying to figure this out for a while now.

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.