Kitz ADSL Broadband Information
adsl spacer  
Support this site
Home Broadband ISPs Tech Routers Wiki Forum
 
     
   Compare ISP   Rate your ISP
   Glossary   Glossary
 
Please login or register.

Login with username, password and session length
Advanced search  

News:

Author Topic: C++ Conundrum  (Read 5836 times)

silversurfer44

  • Kitizen
  • ****
  • Posts: 4421
  • Lord Muck
    • Ben Novice Weather
C++ Conundrum
« on: January 23, 2012, 11:49:14 AM »

I am attempting to port a program written in C to C++.
For the most part it is fairly straight forward, however I have this particular problem that I just cannot get my head round.
It's our good old friend a Struct and an Array of said Struct.
As in :-
struct record {
   char name[22];
   int pos;
   secondName;
   float scale;
} arrayOfStruct[] = {"Diddy Dum"   ,  0, "Diddy Dee",  1.0},/.................etc.............../

From all that I know and the many readings I should be able to and indeed can declare a class in place of the Struct :-

class record
{
    public:
    record(const char *, int, const char *, double);

    const char *name;
    int pos;
    const char *otherName;
    double scale;
};

And Declare a class containing the record class :-
class format
{
public:
    format();
    record format[256];
    void setArray();
public:
};

How do I intialize the record format array to contain the the data from the Struct or the other way round. I am doing my head in with this.
Any help will be appreciated. I will keep on googling for an answer in the mean time. Thank you.
Logged
Colin II : It's no good being a pessimist, it wouldn't work anyway.

tonyappuk

  • Reg Member
  • ***
  • Posts: 589
Re: C++ Conundrum
« Reply #1 on: January 23, 2012, 12:04:24 PM »

I have tried more than once to move from C to C++ and have always failed  and gone back after trying to do something like this. Could you try one of the C++ Newsgroups? A quick look shows there are many where you could put a query like this. Just a suggestion.
Tony
Logged

silversurfer44

  • Kitizen
  • ****
  • Posts: 4421
  • Lord Muck
    • Ben Novice Weather
Re: C++ Conundrum
« Reply #2 on: January 23, 2012, 12:13:17 PM »

Thanks for the suggestion Tony, but I have looked and looked through a good few forums. All the answers tend to start off with good intentions but soon go off at a tangent. I have found a part answer but it will not transpire into what I want. I could re-write the thing but we are talking about a lot of repetitive coding, that a few people have already written.
I am re-inventing the wheel because I want to support a weather station in Linux. There are a few C programs that do this, but none of them have a GUI nor do it real time. In other words I am a glutton for punishment:)
Logged
Colin II : It's no good being a pessimist, it wouldn't work anyway.

broadstairs

  • Kitizen
  • ****
  • Posts: 3700
Re: C++ Conundrum
« Reply #3 on: January 23, 2012, 02:06:47 PM »

Re weather stations are you aware of Weather Display see http://www.weather-display.com/index.php which does have a GUI version for Linux, not as fully functional as the Windows version but does quite a lot and supports quite a few station types.

Stuart
Logged
ISP:Vodafone Router:Vodafone Wi-Fi hub FTTP

silversurfer44

  • Kitizen
  • ****
  • Posts: 4421
  • Lord Muck
    • Ben Novice Weather
Re: C++ Conundrum
« Reply #4 on: January 23, 2012, 02:19:00 PM »

That looked very interesting. I just got a bit of a shock when I read $70 at the bottom of the screen. :o
Seriously though it does look very good. But what's the fun in buying ready made when I can make one. If I get to throwing the towel in I will have another look. I'll carry on running Cumulus in vbox for now.
Thanks for the suggestion.
Logged
Colin II : It's no good being a pessimist, it wouldn't work anyway.

tickmike

  • Kitizen
  • ****
  • Posts: 3641
  • Yes Another Penguin !. :)
Re: C++ Conundrum
« Reply #5 on: January 23, 2012, 02:37:18 PM »

In other words I am a glutton for punishment

It keeps the brain active and the Alzheimer a bit further away  :lol:
Logged
I have a set of 6 fixed IP's From  Eclipse  isp.BT ADSL2(G992.3) line>HG612 as a Modem, Bridge, WAN Not Bound to LAN1 or 2 + Also have FTTP (G.984) No One isp Fixed IP >Dual WAN pfSense (Hardware Firewall and routing).> Two WAN's, Ethernet LAN, DMZ LAN, Zyxel GS1100-24 Switch.

silversurfer44

  • Kitizen
  • ****
  • Posts: 4421
  • Lord Muck
    • Ben Novice Weather
Re: C++ Conundrum
« Reply #6 on: January 23, 2012, 03:30:58 PM »

 :oldman: The biggest problem is walking away from the puwter and remembering what I was about to do before I left.
The times I have sat on the throne and come up with a clear action and forgot what it was by the time I get back to the pc.
Logged
Colin II : It's no good being a pessimist, it wouldn't work anyway.

burakkucat

  • Respected
  • Senior Kitizen
  • *
  • Posts: 38300
  • Over the Rainbow Bridge
    • The ELRepo Project
Re: C++ Conundrum
« Reply #7 on: January 24, 2012, 12:53:49 AM »

Quote
The times I have sat on the throne and come up with a clear action and forgot what it was by the time I get back to the pc.

With a source of paper to hand, all you should need is a pencil and so note down your thoughts. Just make sure you don't use the paper and flush away your notes . . .  ;D
Logged
:cat:  100% Linux and, previously, Unix. Co-founder of the ELRepo Project.

Please consider making a donation to support the running of this site.

silversurfer44

  • Kitizen
  • ****
  • Posts: 4421
  • Lord Muck
    • Ben Novice Weather
Re: C++ Conundrum
« Reply #8 on: January 24, 2012, 07:16:56 AM »

Not very good for writing on that paper. Not that I have tried it mind. :)
Most of the ideas that I do get are quite worthy of being on the said paper as they are of the right consistency, and about as much use. :)
Logged
Colin II : It's no good being a pessimist, it wouldn't work anyway.

silversurfer44

  • Kitizen
  • ****
  • Posts: 4421
  • Lord Muck
    • Ben Novice Weather
Re: C++ Conundrum
« Reply #9 on: January 24, 2012, 03:24:43 PM »

 :clap: :clap2: :dance:

There I was on the throne. A bit constipated so plenty of time. I eventually worked it out with a pencil.
On with the next problem now.
Logged
Colin II : It's no good being a pessimist, it wouldn't work anyway.

roseway

  • Administrator
  • Senior Kitizen
  • *
  • Posts: 43608
  • Penguins CAN fly
    • DSLstats
Re: C++ Conundrum
« Reply #10 on: January 24, 2012, 03:39:22 PM »

>>>> A bit constipated so plenty of time. I eventually worked it out with a pencil.

 ;D
Logged
  Eric

UncleUB

  • Helpful
  • Senior Kitizen
  • *
  • Posts: 29543
Re: C++ Conundrum
« Reply #11 on: January 24, 2012, 04:55:49 PM »

:clap: :clap2: :dance:

There I was on the throne. A bit constipated so plenty of time. I eventually worked it out with a pencil.
On with the next problem now.

Constipation  =   Pencil............... :sick:  :lol:
Logged

camallison

  • Kitizen
  • ****
  • Posts: 1357
Re: C++ Conundrum
« Reply #12 on: January 24, 2012, 05:05:27 PM »

It must have been a propelling pencil!  Boom boom!

Colin
Logged

sevenlayermuddle

  • Helpful
  • Addicted Kitizen
  • *
  • Posts: 5369
Re: C++ Conundrum
« Reply #13 on: January 25, 2012, 11:41:36 AM »

 :lol:
Logged
 

anything