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 8691377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:06:47+00:00 2026-06-13T00:06:47+00:00

I want to creat a C++ class which is incorporated only with static functions

  • 0

I want to creat a C++ class which is incorporated only with static functions that I can use no matter what. I have create a .h file with the declarations and a .cpp file with the definitions. However, when I am using it inside my code I am receiving some weird error messages which I do not know how to solve.

Here is the content of my Utils.h file:

#include <iostream>
#include <fstream>
#include <sstream>

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>

using namespace std;
using namespace cv;

#include <vector>
#include <opencv/cv.h>
#include <opencv/cxcore.h>

class Utils
{
public:
    static void drawPoint(Mat &img, int R, int G, int B, int x, int y);
};

Here is the content of my Utils.cpp file:

#include "Utils.h"

void Utils::drawPoint(Mat &img, int R, int G, int B, int x, int y)
{
img.at<Vec3b>(x, y)[0] = R;
img.at<Vec3b>(x, y)[1] = G;
img.at<Vec3b>(x, y)[2] = B;
}

And this is how I want to use it in my main function :

#include <iostream>
#include <fstream>
#include <sstream>

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>

using namespace std;
using namespace cv;

#include <vector>
#include <opencv/cv.h>
#include <opencv/cxcore.h>

#include "CThinPlateSpline.h"
#include "Utils.h"

int main()
{
Mat img = imread("D:\\image.png");
if (img.empty()) 
{
    cout << "Cannot load image!" << endl;
    system("PAUSE");
    return -1;
}
Utils.drawPoint(img, 0, 255, 0, 20, 20);
imshow("Original Image", img);
waitKey(0);
return 0;
}

And here are the errors that I am receiving.

Can someone point me out what I am doing wrong? What am I missing?

  • 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-13T00:06:48+00:00Added an answer on June 13, 2026 at 12:06 am
    Utils::drawPoint(img, 0, 255, 0, 20, 20);
         ^^ (not period)
    

    is how you would call a static function. the period is for member access (i.e. when you have an instance).

    to illustrate this for completeness:

    Utils utils; << create an instance
    utils.drawPoint(img, 0, 255, 0, 20, 20);
         ^ OK here
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a kind of utility class which contains only static methods
I want to create a class which is derived from QLineEdit ,but I can
I want to create a class that initializes a timer which will be used
my question is simple. I have class TouchSurfaceView which extends GLSurfaceView. I want create
I want to create a constructor for my thread class which can create a
I want to create a class which uses PDO to interact with MySQL. Can
I want to create a class which wraps a list of structures. I have
Let us say that I want to create a class MyString which is a
I am create a Class which have a UIWebView property. I want to set
Basically I'm trying to create a SessionManager class which I can use to manage

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.