How to add a new attribute to an existing PLM object

Is there any example how to add a new attribute to an existing PLM object? I have the following code implemented but not sure if this is the right thing to do CAACAA C++ 

CATIType_var spPLMType;
/*
* extra code...
* spPLMType is not empty
*/

// Build the attribute set to query
		CATAdpPLMQueryAttributeSet objPLMQueryAttrSetNew;
		hr = objPLMQueryAttrSetNew.AddStringAttribute("My new attribute", "My attribute value", CATAdpPLMQueryAttributeOperator::COND_LIKE);
		if (SUCCEEDED(hr))
		{
			CATAdpPLMComponentsInfos objComponentsInfos;
			CATAdpPLMQueryFilter objPLMQueryFilter(spPLMType, objPLMQueryAttrSetNew);
			objPLMQueryFilter.CaseSensitiveMode();
			// Retrieve the element from database by using filter
			hr = CATAdpPLMExtendedQueryServices::GetElementsFromQueryFilter(objPLMQueryFilter, objComponentsInfos);
		}