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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Huh? Help?

Huh? Help?

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
6 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.
  • R Offline
    R Offline
    Ryan B
    wrote on last edited by
    #1
    file_length = (int) src_topic_file->GetLength();
    total_topics = file_length / TOPIC_SIZE;
    TopicVector.SetSize(total_topics);
    
    for (int i=0; i<total_topics; i++)
    {
    	src_topic_file->Seek(TOPIC_SIZE*i,0);
    	dwRead = src_topic_file->Read(buffer, TOPIC_SIZE);
    	topic.SetTopicData((TOPIC*)buffer);
    	TopicVector.Add(topic);
    }
    

    TopicVector is CArray<CTopicItem,CTopicItem> topic is CTopicItem as well (derived from CObject) I have a Compile Error on the .Add line with Cannot Convert Parameter 1 from CTopicItem to CTopicItem am I doing something wrong? Ryan Baillargeon Software Specialist Fuel Cell Technologies Inc.

    T 1 Reply Last reply
    0
    • R Ryan B
      file_length = (int) src_topic_file->GetLength();
      total_topics = file_length / TOPIC_SIZE;
      TopicVector.SetSize(total_topics);
      
      for (int i=0; i<total_topics; i++)
      {
      	src_topic_file->Seek(TOPIC_SIZE*i,0);
      	dwRead = src_topic_file->Read(buffer, TOPIC_SIZE);
      	topic.SetTopicData((TOPIC*)buffer);
      	TopicVector.Add(topic);
      }
      

      TopicVector is CArray<CTopicItem,CTopicItem> topic is CTopicItem as well (derived from CObject) I have a Compile Error on the .Add line with Cannot Convert Parameter 1 from CTopicItem to CTopicItem am I doing something wrong? Ryan Baillargeon Software Specialist Fuel Cell Technologies Inc.

      T Offline
      T Offline
      Tomasz Sowinski
      wrote on last edited by
      #2

      Did you make CTopicItem copy c'tor protected or private? CArray::Add uses 2nd template argument as data type of its parameter, so basically you're passing CTopicItem by value, which involves copying. Tomasz Sowinski -- http://www.shooltz.com

      *** Si fractum non sit, noli id reficere. ***

      R 1 Reply Last reply
      0
      • T Tomasz Sowinski

        Did you make CTopicItem copy c'tor protected or private? CArray::Add uses 2nd template argument as data type of its parameter, so basically you're passing CTopicItem by value, which involves copying. Tomasz Sowinski -- http://www.shooltz.com

        *** Si fractum non sit, noli id reficere. ***

        R Offline
        R Offline
        Ryan B
        wrote on last edited by
        #3

        Thank you. (for making me revel in my own stupidity). The class didnt have the = or copy constructor. Ryan Baillargeon Software Specialist Fuel Cell Technologies Inc.

        T 1 Reply Last reply
        0
        • R Ryan B

          Thank you. (for making me revel in my own stupidity). The class didnt have the = or copy constructor. Ryan Baillargeon Software Specialist Fuel Cell Technologies Inc.

          T Offline
          T Offline
          Tomasz Sowinski
          wrote on last edited by
          #4

          You may consider changing 2nd CArray template argument to const CTopicItem & anyway. This will change the way arguments are passed to CArray::Add and few other methods. Tomasz Sowinski -- http://www.shooltz.com

          *** Si fractum non sit, noli id reficere. ***

          R 1 Reply Last reply
          0
          • T Tomasz Sowinski

            You may consider changing 2nd CArray template argument to const CTopicItem & anyway. This will change the way arguments are passed to CArray::Add and few other methods. Tomasz Sowinski -- http://www.shooltz.com

            *** Si fractum non sit, noli id reficere. ***

            R Offline
            R Offline
            Ryan B
            wrote on last edited by
            #5

            Can you please show me what my operator= function should look like? Ryan Baillargeon Software Specialist Fuel Cell Technologies Inc.

            T 1 Reply Last reply
            0
            • R Ryan B

              Can you please show me what my operator= function should look like? Ryan Baillargeon Software Specialist Fuel Cell Technologies Inc.

              T Offline
              T Offline
              Tomasz Sowinski
              wrote on last edited by
              #6

              It depends on the internals of CTopicItem of course. Tomasz Sowinski -- http://www.shooltz.com

              *** Si fractum non sit, noli id reficere. ***

              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