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. string Array

string Array

Scheduled Pinned Locked Moved C / C++ / MFC
data-structureshelptutorialquestion
6 Posts 5 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.
  • J Offline
    J Offline
    J5121982
    wrote on last edited by
    #1

    CStringArray myclass::getStr() { CStringArray csa; csa.Add("str1"); csa.Add("str2"); return csa; } I got this error what to do? error C2558: class 'CStringArray' : no copy constructor available How to return two dimensional array? JAYARAJ

    A R H 3 Replies Last reply
    0
    • J J5121982

      CStringArray myclass::getStr() { CStringArray csa; csa.Add("str1"); csa.Add("str2"); return csa; } I got this error what to do? error C2558: class 'CStringArray' : no copy constructor available How to return two dimensional array? JAYARAJ

      A Offline
      A Offline
      Arvind Bharti
      wrote on last edited by
      #2

      Rather than returning the value, pass the paramter as a reference. void myclass::getStr(CStringArray& csa) { csa.Add("str1"); csa.Add("str2"); }

      1 Reply Last reply
      0
      • J J5121982

        CStringArray myclass::getStr() { CStringArray csa; csa.Add("str1"); csa.Add("str2"); return csa; } I got this error what to do? error C2558: class 'CStringArray' : no copy constructor available How to return two dimensional array? JAYARAJ

        R Offline
        R Offline
        Rage
        wrote on last edited by
        #3

        This is my code snippet, and it does not work, since CStringArray does not implement a copy constructor (meaning that this probably fails to compile:

        CStringArray csa=getStr();

        Do as suggested above, pass the CStringArray as an argument to the function. ~RaGE();

        1 Reply Last reply
        0
        • J J5121982

          CStringArray myclass::getStr() { CStringArray csa; csa.Add("str1"); csa.Add("str2"); return csa; } I got this error what to do? error C2558: class 'CStringArray' : no copy constructor available How to return two dimensional array? JAYARAJ

          H Offline
          H Offline
          Hamid Taebi
          wrote on last edited by
          #4

          maybe it is some helpful to you ////h File//////////// CStringArray *a(); CStringArray* CAnswer::a() { CStringArray* a; a=new (CStringArray); a->Add("123"); a->Add("12"); return a; } if you check count then return ->2 CStringArray *b; b=a(); int cb=b->GetCount();

          A 1 Reply Last reply
          0
          • H Hamid Taebi

            maybe it is some helpful to you ////h File//////////// CStringArray *a(); CStringArray* CAnswer::a() { CStringArray* a; a=new (CStringArray); a->Add("123"); a->Add("12"); return a; } if you check count then return ->2 CStringArray *b; b=a(); int cb=b->GetCount();

            A Offline
            A Offline
            Arman S
            wrote on last edited by
            #5

            Hi, Works. Yet not a good solution. The caller is supposed to delete the array though it may not do it. The best choice, I think, is to pass by refernce as a parameter. -- ====== Arman

            H 1 Reply Last reply
            0
            • A Arman S

              Hi, Works. Yet not a good solution. The caller is supposed to delete the array though it may not do it. The best choice, I think, is to pass by refernce as a parameter. -- ====== Arman

              H Offline
              H Offline
              Hamid Taebi
              wrote on last edited by
              #6

              yes It's only a suggestion because we need to delete array

              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