Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Assignment of Type at Run-Time

Assignment of Type at Run-Time

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionphp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LiquidE_SA
    wrote on last edited by
    #1

    Imagine such a situation: you have a template data structure class, and you want to stream data from a file into your data structure. Values in the file should all be of the same primitive type, but the type itself is not recorded anywhere explicitly. And the question is: in the main program, how would you find out the type of values that a specific file stores? Because the type is needed to instantiate the data structure before you can start streaming data in... If you guys want to understand the whole problem the link for the Project can be found at: http://www.cs.up.ac.za/download.php/COS212/Assignments/project1.pdf or http://www.cs.up.ac.za/download.php/COS212/Assignments/project1.ps I've been struggling to find a sollution to this problem for weeks now. The project has to be in tomorrow. Help would GREATLY be appreciated. Thanks alot

    M 1 Reply Last reply
    0
    • L LiquidE_SA

      Imagine such a situation: you have a template data structure class, and you want to stream data from a file into your data structure. Values in the file should all be of the same primitive type, but the type itself is not recorded anywhere explicitly. And the question is: in the main program, how would you find out the type of values that a specific file stores? Because the type is needed to instantiate the data structure before you can start streaming data in... If you guys want to understand the whole problem the link for the Project can be found at: http://www.cs.up.ac.za/download.php/COS212/Assignments/project1.pdf or http://www.cs.up.ac.za/download.php/COS212/Assignments/project1.ps I've been struggling to find a sollution to this problem for weeks now. The project has to be in tomorrow. Help would GREATLY be appreciated. Thanks alot

      M Offline
      M Offline
      Maximilien
      wrote on last edited by
      #2

      As I understand, you have to use a template to create your tree, but you will manually select which type according to the input file. for example, you will read int if the file contain int, double if te file contain double, ... YourTreeStructure <int > yourIntTree; YourTreeStructure< double > yourDoubleTree;


      Maximilien Lincourt Your Head A Splode - Strong Bad

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups