Using QString as the parameter : QString « Qt « C++






Using QString as the parameter

  
#include <QString>
#include <qstd.h>
using namespace qstd;

class Person {

public:
    void setNameV( QString newName) {
        newName += " A";  
        m_Name = newName;
    }

    void setNameCR( const QString& newName) {
        m_Name = newName;
    }
    void setNameR( QString& newName) {
        newName += " B";
        m_Name = newName;
    }
    QString m_Name;
};


int main() {
    Person p;
    QString name("1");
    p.setNameCR(name);  
    p.setNameCR("2"); 
    p.setNameV("3");  
    p.setNameR(name);     
    cout << name;         
}

   
    
  








Related examples in the same category

1.Complete demo for QString
2.Format command line parameter with QString
3.extends QString
4.cpp with qstring
5.Qt type size