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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:47:32+00:00 2026-06-08T09:47:32+00:00

I’m starting the process of learning C++ and object oriented design . What are

  • 0

I’m starting the process of learning C++ and object oriented design. What are the known / common techniques for converting procedural code to object-oriented code? What design choices make sense for the following code?

typedef struct
{
    int sector;
    int sectorPos;
}EndPosition;

typedef struct
{
    int rotateAngles;
    double brakingFactor;
}WheelStop;

WheelStop stops[][6] =
{
     /* data removed for brevity */
};

typedef struct
{
    int numImages;      /* Number of images in win amount string */
    int pixWidth;
    int indexes[7];     /* indexes into NumberImages[] */
}WinAmountData;

typedef struct
{
    int xOffset;    /* pixel count offset before next digit */
    std::string fileName;
    //char fileName[20];
    cairo_surface_t *image; 
}ImageInfo;

ImageInfo NumberImages[] =
{
     /* data removed for brevity */
};

enum { DOLLAR = 10, EURO, POUND, YEN };

double DegreesToRadians( double degrees )
{
    return((double)((double)degrees * ( (double)M_PI/(double)180.0 )));
}

int InitImages( void )
{
     /* uses NumberImages */
}


void DestroyNumberImages( void )
{
      /* uses NumberImages */
}

int ParseWinAmountString( char *string, WinAmountData *amtData )
{
        /* uses WinAmountData and enum */
}

gboolean rotate_cb( void *StopPos )
{
      /* uses EndPosition and stops */
}

static gboolean on_expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
     /* uses CairoImage class */
}

static void destroy (GtkWidget *window, gpointer data)
{
     /* cleanup GTK stuff */
}

I’ve given it some thought, and I can see maybe two classes:

  • CWinAmount which would encompass the data structures and functions that handle the currency amounts to be placed on the “spinning wheel”.
  • CWheel which would encapsulate the wheel data structures and functions that control the wheel animation mechanics.

But I’m just not sure if this is a good design.

  • 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-08T09:47:34+00:00Added an answer on June 8, 2026 at 9:47 am

    I’m not going to provide exact details on how to do such a conversion (that’s really up to you). But, your described approach sounds like a perfectly reasonable design. Generally when converting code to OO I find the most obvious groupings of functions and structs with shared state and wrap those together. Then I look at what functions are remained and try to determine if they belong to an existing object, have some relation that could justify grouping them, or leave them as generic functions (if I have the option).

    In general there’s no secret to converting to OO style and most approaches simply try to group any/all shared state/functionality into blocks (objects).

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
i got an object with contents of html markup in it, for example: string
I have thousands of HTML files to process using Groovy/Java and I need to
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.